@@ -79,6 +79,11 @@ def get(base, url, path, checksums, verbose=False):
79
79
eprint ("removing" , temp_path )
80
80
os .unlink (temp_path )
81
81
82
+ def curl_version ():
83
+ m = re .match (bytes ("^curl ([0-9]+)\\ .([0-9]+)" , "utf8" ), require (["curl" , "-V" ]))
84
+ if m is None :
85
+ return (0 , 0 )
86
+ return (int (m [1 ]), int (m [2 ]))
82
87
83
88
def download (path , url , probably_big , verbose ):
84
89
for _ in range (4 ):
@@ -107,11 +112,15 @@ def _download(path, url, probably_big, verbose, exception):
107
112
# If curl is not present on Win32, we should not sys.exit
108
113
# but raise `CalledProcessError` or `OSError` instead
109
114
require (["curl" , "--version" ], exception = platform_is_win32 ())
110
- run (["curl" , option ,
115
+ extra_flags = []
116
+ if curl_version () > (7 , 70 ):
117
+ extra_flags = [ "--retry-all-errors" ]
118
+ run (["curl" , option ] + extra_flags + [
111
119
"-L" , # Follow redirect.
112
120
"-y" , "30" , "-Y" , "10" , # timeout if speed is < 10 bytes/sec for > 30 seconds
113
121
"--connect-timeout" , "30" , # timeout if cannot connect within 30 seconds
114
122
"-o" , path ,
123
+ "--continue-at" , "-" ,
115
124
"--retry" , "3" , "-SRf" , url ],
116
125
verbose = verbose ,
117
126
exception = True , # Will raise RuntimeError on failure
0 commit comments