Created
August 16, 2013 12:55
-
-
Save abbotto/6249651 to your computer and use it in GitHub Desktop.
Python: Display the download percentage of a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def report(count, blockSize, totalSize): | |
| percent = int(count*blockSize*100/totalSize) | |
| sys.stdout.write("\r%d%%" % percent + ' complete') | |
| sys.stdout.flush() | |
| sys.stdout.write('\rFetching ' + name + '...\n') | |
| urllib.urlretrieve(getFile, saveFile, reporthook=report) | |
| sys.stdout.write("\rDownload complete, saved as %s" % (fileName) + '\n\n') | |
| sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment