A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/329290.html below:

FTP status problems. (Again)

FTP status problems. (Again)Nainto Nainto at gmail.com
Sat Sep 17 09:08:02 EDT 2005
When I execute  the folllowing code with all of the address, username,
and passwords filled out I gt an error saying:
"/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python"
"/Users/zacim/Documents/FireUpFTP/foramttedthing" ; exit
Traceback (most recent call last):
  File "/Users/zacim/Documents/FireUpFTP/foramttedthing", line 26, in ?
    fname = sys.argv[1]
IndexError: list index out of range
logout
[Process completed]

This is the 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__':
	import sys
	fname = sys.argv[1]
	f = ProgressFile(fname)
	f.read()

ftp = ftplib.FTP("ftp.sadpanda.cjb.cc")
ftp.login("sadpanda","s4dp4nd4b1g")
file = "/FrenchBrochure.pages.zip.gz"
ftp.storbinary("STOR " + file, ProgressFile(file, "rb"), 1024)
ftp.quit()


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4