FtpUtils Progress Bar

I

iwcook58

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
 
T

Timothy Smith

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)+'%')
 
G

George Sakkis

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
 
J

Justin Ezequiel

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, 32768)
f.close()
c.quit()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top