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()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to