Use the internal download() function rather than curl

This commit is contained in:
Joe Rickerby
2020-01-31 17:06:58 +00:00
parent 1a7d1d8cb1
commit a143ff2bfd
3 changed files with 37 additions and 33 deletions
+1 -29
View File
@@ -1,6 +1,5 @@
from __future__ import print_function
import os, tempfile, subprocess, shutil, sys
from time import sleep
from collections import namedtuple
from glob import glob
@@ -9,12 +8,7 @@ try:
except ImportError:
from pipes import quote as shlex_quote
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from .util import prepare_command, get_build_verbosity_extra_flags
from .util import prepare_command, get_build_verbosity_extra_flags, download
IS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
@@ -64,28 +58,6 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
args = ['cmd', '/E:ON', '/V:ON', '/C'] + args
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
def download(url, dest):
print('+ Download ' + url + ' to ' + dest)
dest_dir = os.path.dirname(dest)
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
repeat_num = 3
for i in range(repeat_num):
try:
response = urlopen(url)
except:
if i == repeat_num - 1:
raise
sleep(3)
continue
break
try:
with open(dest, 'wb') as file:
file.write(response.read())
finally:
response.close()
if IS_RUNNING_ON_AZURE or IS_RUNNING_ON_TRAVIS:
shell = simple_shell
else: