title: How to make a download with progress bar in Python?
body: <p>I am trying to implement this package <a href="http://code.google.com/p/python-progressbar/" rel="nofollow noreferrer">http://code.google.com/p/python-progressbar/</a> when downloading a file like below:</p>
  
  <pre><code>    def dlProgress(count, blockSize, totalSize):
          widgets = ['Test: ', Percentage(), ' ', Bar(marker=RotatingMarker()), ' ', ETA(), ' ', FileTransferSpeed()]
          pbar = ProgressBar(widgets=widgets, maxval=totalSize).start()
          for count in range(totalSize):
              #print count
              pbar.update(int(count*blockSize*100/totalSize))
          pbar.finish()            
      urllib.urlretrieve(url, fileName, reporthook=dlProgress)
  </code></pre>
  
  <p>The problem is that the progress bar goes to 100% before the real download progress finished, and it continues to begin the new bar, like  this:</p>
  
  <pre><code>Test: 100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 0:00:31 402.06 kB/s
  Test: 100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 0:00:31 408.39 kB/s
  Test: 100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 0:00:32 389.47 kB/s
  </code></pre>