| # Simple Python script to download a file. Used as a fallback |
| # when other more reliable methods fail. |
| from __future__ import print_function |
| from urllib.request import urlretrieve |
| USING = "urllib.request.urlretrieve" |
| from urllib import urlretrieve |
| USING = "urllib.retrieve" |
| print("Python at", sys.executable, "is not suitable", |
| "for downloading files.", file=sys.stderr) |
| def urlretrieve(url, filename): |
| r = get(url, stream=True) |
| with open(filename, 'wb') as f: |
| for chunk in r.iter_content(chunk_size=1024): |
| if __name__ == '__main__': |
| print("Usage: urlretrieve.py [url] [filename]", file=sys.stderr) |
| print("Downloading from", URL, "to", FILENAME, "using", USING) |
| urlretrieve(URL, FILENAME) |