Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > FtpUtils Progress Bar

Reply
Thread Tools

FtpUtils Progress Bar

 
 
iwcook58@gmail.com
Guest
Posts: n/a
 
      09-14-2006
Hi,
I can successfully upload and download files using Stefan's Schwarzer's
ftputil script.

The problem is that as some of the files are quite large you cannot see
how much has been downloaded/uploaded.
Even a percentage or just dots going across the screen would be better
than nothing.

Does anyone have an example on how to show the progress of the
upload/download when using ftputil?

Thanks in advance.

Kind regards
Ian Cook

 
Reply With Quote
 
 
 
 
Timothy Smith
Guest
Posts: n/a
 
      09-14-2006
wrote:
> Hi,
> I can successfully upload and download files using Stefan's Schwarzer's
> ftputil script.
>
> The problem is that as some of the files are quite large you cannot see
> how much has been downloaded/uploaded.
> Even a percentage or just dots going across the screen would be better
> than nothing.
>
> Does anyone have an example on how to show the progress of the
> upload/download when using ftputil?
>
> Thanks in advance.
>
> Kind regards
> Ian Cook
>
>

try this

def _reporthook(numblocks, blocksize, filesize, url=None):
base = os.path.basename(url)
try:
percent =
min((numblocks*blocksize*100)/filesize, 100)
except:
percent = 100
if numblocks != 0:
print str(percent)+'%')
 
Reply With Quote
 
 
 
 
George Sakkis
Guest
Posts: n/a
 
      09-14-2006
wrote:
> Hi,
> I can successfully upload and download files using Stefan's Schwarzer's
> ftputil script.
>
> The problem is that as some of the files are quite large you cannot see
> how much has been downloaded/uploaded.
> Even a percentage or just dots going across the screen would be better
> than nothing.
>
> Does anyone have an example on how to show the progress of the
> upload/download when using ftputil?


You'll probably have more luck asking at
http://codespeak.net/mailman/listinfo/ftputil.

George

 
Reply With Quote
 
Justin Ezequiel
Guest
Posts: n/a
 
      09-14-2006
wrote:
>
> Does anyone have an example on how to show the progress of the
> upload/download when using ftputil?
>


haven't used ftputil in quite a while ...
but using ftplib...

import ftplib

class Callback(object):
def __init__(self, totalsize, fp):
self.totalsize = totalsize
self.fp = fp
self.received = 0

def __call__(self, data):
self.fp.write(data)
self.received += len(data)
print '\r%.3f%%' % (100.0*self.received/self.totalsize),

if __name__ == '__main__':
host = 'ftp.microsoft.com'
src = '/deskapps/games/public/Hellbender/heltrial.exe'
c = ftplib.FTP(host)
c.login()
size = c.size(src)
dest = 'heltrial.exe'
f = open(dest, 'wb')
w = Callback(size, f)
c.set_pasv(0)
c.retrbinary('RETR %s' % src, w, 3276
f.close()
c.quit()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
disable title bar, status bar, and address bar of a window Matt HTML 9 08-23-2004 07:49 PM
Re: disable title bar, status bar, and address bar of a browser window John Hann ASP .Net 0 08-21-2004 05:07 AM
disable title bar, status bar, and address bar of a browser window Matt ASP .Net 0 08-21-2004 03:50 AM
Progress bar to show the progress of a task Charlie Zhang Java 3 08-16-2004 05:53 PM
progress bar or guage bar Rob ASP General 6 07-12-2003 09:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57