FtpUtils Progress Bar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwcook58@gmail.com

    #1

    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

  • Timothy Smith

    #2
    Re: FtpUtils Progress Bar

    iwcook58@gmail. com 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(num blocks, blocksize, filesize, url=None):
    base = os.path.basenam e(url)
    try:
    percent =
    min((numblocks* blocksize*100)/filesize, 100)
    except:
    percent = 100
    if numblocks != 0:
    print str(percent)+'% ')

    Comment

    • George Sakkis

      #3
      Re: FtpUtils Progress Bar

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

      Comment

      • Justin Ezequiel

        #4
        Re: FtpUtils Progress Bar

        iwcook58@gmail. com 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(d ata)
        self.received += len(data)
        print '\r%.3f%%' % (100.0*self.rec eived/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('R ETR %s' % src, w, 32768)
        f.close()
        c.quit()

        Comment

        Working...