FTP status problems. (Again)

Nainto Nainto at gmail.com
Fri Sep 16 22:27:54 EDT 2005


Hello, I have posted before about trying to find the status of an FTP
uplaod but couldn't get anything to work. After some more searching I
found
http://groups.google.com/group/comp.lang.python/browse_thread/thread/76be9a994547db4/91917c906cdc04d4?q=ftp+progress&rnum=1#91917c906cdc04d4
but it does not seem to work because it just uploads the file and does
not print a . onto the screen. HEre is the code I have when I'm using
the code from that link.
import ftplib
import os
class dot_FTP(ftplib.FTP):
	def storbinary(self, cmd, fp, blocksize=8192):
		self.voidcmd('TYPE I')
		conn = self.transfercmd(cmd)
		while 1:
			buf = fp.read(blocksize)
			if not buf: break
			conn.send(buf)
			sys.stdout.write('.')
			sys.stdout.flush()
		conn.close()
		return self.voidresp()


ftp = ftplib.FTP("FTPADDRESS")
ftp.login("user","pass")
file = "/file"
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
ftp.quit()
Does anyone know why this is not working? IS there any other way to
find out when a chunc has been sent or the bytes uploaded of a file?
Thanks.




More information about the Python-list mailing list