@@ -44,7 +44,6 @@ def eprint(*args, **kwargs):
44
44
kwargs ["file" ] = sys .stderr
45
45
print (* args , ** kwargs )
46
46
47
-
48
47
def get (base , url , path , checksums , verbose = False ):
49
48
with tempfile .NamedTemporaryFile (delete = False ) as temp_file :
50
49
temp_path = temp_file .name
@@ -89,6 +88,8 @@ def download(path, url, probably_big, verbose):
89
88
eprint ("\n spurious failure, trying again" )
90
89
_download (path , url , probably_big , verbose , False )
91
90
91
+ def has_wget ():
92
+ require (["wget" , "--version" ], exit = False ) != None
92
93
93
94
def _download (path , url , probably_big , verbose , exception ):
94
95
# Try to use curl (potentially available on win32
@@ -100,22 +101,29 @@ def _download(path, url, probably_big, verbose, exception):
100
101
eprint ("downloading {}" .format (url ))
101
102
102
103
try :
103
- if (probably_big or verbose ) and "GITHUB_ACTIONS" not in os .environ :
104
- option = "-#"
104
+ if has_wget ():
105
+ eprint ("using wget!!" );
106
+ run (["wget" , "--show-progress" , "-O" , path , "url" ],
107
+ verbose = verbose ,
108
+ exception = True ,
109
+ )
105
110
else :
106
- option = "-s"
107
- # If curl is not present on Win32, we should not sys.exit
108
- # but raise `CalledProcessError` or `OSError` instead
109
- require (["curl" , "--version" ], exception = platform_is_win32 ())
110
- run (["curl" , option ,
111
- "-L" , # Follow redirect.
112
- "-y" , "30" , "-Y" , "10" , # timeout if speed is < 10 bytes/sec for > 30 seconds
113
- "--connect-timeout" , "30" , # timeout if cannot connect within 30 seconds
114
- "-o" , path ,
115
- "--retry" , "3" , "-SRf" , url ],
116
- verbose = verbose ,
117
- exception = True , # Will raise RuntimeError on failure
118
- )
111
+ if (probably_big or verbose ) and "GITHUB_ACTIONS" not in os .environ :
112
+ option = "-#"
113
+ else :
114
+ option = "-s"
115
+ # If curl is not present on Win32, we should not sys.exit
116
+ # but raise `CalledProcessError` or `OSError` instead
117
+ require (["curl" , "--version" ], exception = platform_is_win32 ())
118
+ run (["curl" , option ,
119
+ "-L" , # Follow redirect.
120
+ "-y" , "30" , "-Y" , "10" , # timeout if speed is < 10 bytes/sec for > 30 seconds
121
+ "--connect-timeout" , "30" , # timeout if cannot connect within 30 seconds
122
+ "-o" , path ,
123
+ "--retry" , "3" , "-SRf" , url ],
124
+ verbose = verbose ,
125
+ exception = True , # Will raise RuntimeError on failure
126
+ )
119
127
except (subprocess .CalledProcessError , OSError , RuntimeError ):
120
128
# see http://serverfault.com/questions/301128/how-to-download
121
129
if platform_is_win32 ():
@@ -129,6 +137,7 @@ def _download(path, url, probably_big, verbose, exception):
129
137
raise
130
138
131
139
140
+
132
141
def verify (path , expected , verbose ):
133
142
"""Check if the sha256 sum of the given path is valid"""
134
143
if verbose :
0 commit comments