diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index fdd87844..74759dcf 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -76,24 +76,16 @@ def download(path, url, probably_big, verbose): def _download(path, url, probably_big, verbose, exception): if probably_big or verbose: print("downloading {}".format(url)) - # see http://serverfault.com/questions/301128/how-to-download - if sys.platform == 'win32': - run(["PowerShell.exe", "/nologo", "-Command", - "(New-Object System.Net.WebClient)" - ".DownloadFile('{}', '{}')".format(url, path)], - verbose=verbose, - exception=exception) + if sys.version_info[0] == 3: + import urllib.request + response=urllib.request.urlopen(url) + elif sys.version_info[0] == 2: + import urllib + response=urllib.urlopen(url) else: - if probably_big or verbose: - option = "-#" - else: - option = "-s" - run(["curl", option, - "-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds - "--connect-timeout", "30", # timeout if cannot connect within 30 seconds - "--retry", "3", "-Sf", "-o", path, url], - verbose=verbose, - exception=exception) + raise Exception("Unsupported python version") + with open(path,"wb") as fp: + fp.write(response.read()) def verify(path, sha_path, verbose):