I am trying to implement this package http://code.google.com/p/python-progressbar/ when downloading a file like below:
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)
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:
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