FTP status problems. (Again)

Nainto Nainto at gmail.com
Sat Sep 17 21:43:40 CEST 2005


I'm really sorry that I keep having problems with this. :-( Now I get:
TypeError: Error when calling the metaclass bases[] str() takes at most
1 arguement (3 given)

and the Traceback is:

file "formattedthing", line 2, in '?'
classProgressFile(file)

With the following code:

import ftplib
class ProgressFile(file):
	def read(self, size = None):
		from sys import stdout
		if size is not None:
			buff = file.read(self, size)
			if buff:
				stdout.write('.')
			else:
				stdout.write('\n')
			return buff
		else:
			buff = ''
			while True:
				new_str = file.read(self, 1024)
				stdout.write('.')
				if new_str:
					buff = buff + new_str
				else:
					stdout.write('\n')
					break
				return buff
if __name__ == '__main__':
	ftp = ftplib.FTP("ftp.sadpanda.cjb.cc")
	ftp.login("sadpanda","PASSWORDEDITEDOUT")
	file = "/FrenchBrochure.pages.zip"
	ftp.storbinary("STOR " + file, ProgressFile(file, "rb"), 1024)
	ftp.quit()

Thanks so muchy for help guys. :-)




More information about the Python-list mailing list