[Tutor] How to make ftplib show progress while uploading a large file
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 ?
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.
You could either a) install the patch from  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.
 And why not? I don't see any good reason why it shouldn't. A patch
to do this was submitted last year. It would be nice to see this in
2.6. Ruby has it.
More information about the Tutor