Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 14th, 2006, 03:15 AM
iwcook58@gmail.com
Guest
 
Posts: n/a
Default FtpUtils Progress Bar

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

  #2  
Old September 14th, 2006, 03:45 AM
Timothy Smith
Guest
 
Posts: n/a
Default Re: FtpUtils Progress Bar

iwcook58@gmail.com wrote:
Quote:
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)+'%')
  #3  
Old September 14th, 2006, 04:55 AM
George Sakkis
Guest
 
Posts: n/a
Default Re: FtpUtils Progress Bar

iwcook58@gmail.com wrote:
Quote:
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

  #4  
Old September 14th, 2006, 05:35 AM
Justin Ezequiel
Guest
 
Posts: n/a
Default Re: FtpUtils Progress Bar

iwcook58@gmail.com wrote:
Quote:
>
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()

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles