[Tutor] How to make ftplib show progress while uploading a large file

Terry Carroll carroll at tjc.com
Tue Feb 6 05:04:16 CET 2007


On Sun, 4 Feb 2007, [ISO-8859-1] Magnus Wirström wrote:

> I'm workinga on a program that will upload a large file to a server 
> using ftp. I'm using ftplib to do this. I'm using a gui with wxpython 
> and i would like to have a progressbar showing in % how much have been 
> transfered. I have been googling but i can't make any sense of what i 
> have found. does anyone have a good example or could explain how to do 
> this ?

Magnus --

When you installed wxPython, did you also download and install the "Docs, 
Demo, Samples, etc."?  There are great examples of nearly all wxPython 
dialogs, including ProgressDialog.

The hard part is going to get ftplib to talk to your dialog.  You're 
uploading.  ftplib's download methods (retrbinary and retrlines) include a 
callback option, which would let you update the progress as you went, but 
the upload methods (storbinary and storlines) does not.[1]

You could either a) install the patch from [2] on your system (or override 
storbinary and/or storlines as appropriate; or b) wrap the uploaded file 
in a class that updates the dialog every time data gets read. 

Maybe someone else will have a better idea.



[1] And why not?  I don't see any good reason why it shouldn't.  A patch 
to do this was submitted last year.[2]  It would be nice to see this in 
2.6.  Ruby has it.[3]


[2] 
http://sourceforge.net/tracker/index.php?func=detail&aid=1221598&group_id=5470&atid=305470

[3] http://www.rubycentral.com/book/lib_network.html#Net::FTP.storbinary




More information about the Tutor mailing list