Re: [Tutor] ftplib.storbinary and using a progress bar
johnf [EMAIL PROTECTED] wrote the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like retrbinary() so does anyone have a thought on how I can update my user on the progress of the transfer. If you don't fancy getting the 2.6 source as Terry suggested then the other way to do this kind of thing is with a separate thread. Start the new thread which just displays a progress bar (you need to find how big the file is before hand and check progress as you go too) Then in the main thread run the transfer and terminate the progress thread when you finish. How easy this is depends on your familiarity with threads I guess! As threading goes its a fairly straighforward use. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftplib.storbinary and using a progress bar
On Sat, Sep 6, 2008 at 9:49 PM, johnf [EMAIL PROTECTED] wrote: Hi, I'm currently using ftplib.storbinary() to upload a file to a FTP server. However, I would like to inform the user of the progress being made during the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like retrbinary() so does anyone have a thought on how I can update my user on the progress of the transfer. BTW I have to use a binary transfer because the file being transfer is not text. storbinary() is not very complex. You could write your own version that has a callback function. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftplib.storbinary and using a progress bar
On Sun, Sep 7, 2008 at 4:13 AM, Alan Gauld [EMAIL PROTECTED] wrote: johnf [EMAIL PROTECTED] wrote the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like retrbinary() so does anyone have a thought on how I can update my user on the progress of the transfer. If you don't fancy getting the 2.6 source as Terry suggested then the other way to do this kind of thing is with a separate thread. Start the new thread which just displays a progress bar (you need to find how big the file is before hand and check progress as you go too) Then in the main thread run the transfer and terminate the progress thread when you finish. I don't think threading will help here, the problem is that the progress information is not available. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftplib.storbinary and using a progress bar
On Saturday 06 September 2008 06:49:39 pm johnf wrote: Hi, I'm currently using ftplib.storbinary() to upload a file to a FTP server. However, I would like to inform the user of the progress being made during the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like retrbinary() so does anyone have a thought on how I can update my user on the progress of the transfer. BTW I have to use a binary transfer because the file being transfer is not text. Once I took a look at the source for ftplib I decided to subclass the module. I then provided my own method with a callback. For my purpose I just passed an integer back (a counter). But thanks everyone for the help. It was a good lesson anyway. -- John Fabiani ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftplib.storbinary and using a progress bar
Kent Johnson [EMAIL PROTECTED] wrote I don't think threading will help here, the problem is that the progress information is not available. If you are transferring from A to B and can find the size of the file at A and poll the size at B you can display progress. OTOH if that is not available you can still use a thread to indicate that *something* is happening even if you don't know when it will stop. Thus a threaded approach works for providing some kind of user feedback even if nothing else. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftplib.storbinary and using a progress bar
On Sat, 6 Sep 2008, johnf wrote: I'm currently using ftplib.storbinary() to upload a file to a FTP server. However, I would like to inform the user of the progress being made during the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like retrbinary() so does anyone have a thought on how I can update my user on the progress of the transfer. Callbacks are being added in 2.6, and are in the 2.6 source now. You can download the current version of ftplib at http://svn.python.org/view/python/trunk/Lib/ftplib.py?rev=63788view=log When I do something along these lines, I save it (usually under the local directory of the python program that uses it) under a modified name, i.e. ftplib26.py or myftplib.py; then import with: import ftplib26 as ftplib ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor