transmission problem at the requested offset

Kong Hyeog Jun sanzio2001 at hanmail.net
Tue Nov 5 23:51:19 EST 2002


Hi! i had tried to implement the way that the server restarts sending
the file's bytes at the requested offset.
i wrote the following code. but this code didn't work well.
when i typed "a", it didn't perform "Append" operation at the
requested offset "rest"
but it performed "Overwrite" oeration. that is, Append operation is
not implemented.

i don't know what should i do.
anybody can give me any hints?

Thanks.
(sorry, i can not write english as well. my mother language is not
english)

--------------------------------------------------
def do_getFile(self, tar):
	self.do_size(tar)  # it is used to assign the file size of the 
	                   # given "tar" on local host to "self.file_size"
	self.ftp.voidcmd("TYPE I")
	rest = str(os.path.getsize(tar))
	while 1:
		res = string.lower(raw_input("(O)verWrite/(A)ppend/(P)ass ?"))
		if res == "o":
			print 2
			f = file(tar,"w")
			conn = self.ftp.transfercmd("RETR "+tar)
			break
		elif res == "a":
			print 1,rest
			f = file(tar,"a")
			conn = self.ftp.transfercmd("RETR "+tar, rest)
			print 3            			
			break
		elif res == "p":
			return
	flen = 0
	while 1:
		block = conn.recv(8192)
		if len(block) == 0:
			break
		flen = flen + len(block)
		f.write(block)
		print "\r%s downloading :%10dbytes/%sbytes  %5d%%" % (tar,flen ,
self.file_size,int((flen/float(self.file_size))*100)),
	print "\r%s : Downloaded  :%10dKB/%sKB" % (tar,flen, self.file_size)
	conn.close()
	self.ftp.voidresp()
	self.file_size = 0
--------------------------------------------------



More information about the Python-list mailing list