Retry sw download on appveyor

This commit is contained in:
Kovid Goyal 2017-05-09 23:05:58 +05:30
parent 7d7fcd312a
commit 8246e539bc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -9,6 +9,7 @@ import os
import subprocess
import sys
import tarfile
import time
try:
import _winreg as winreg
@ -159,13 +160,22 @@ def printf(*args, **kw):
sys.stdout.flush()
def download_file(url):
for i in range(5):
try:
printf('Downloading', url)
return subprocess.check_output(['curl.exe', '-fsSL', url])
except subprocess.CalledProcessError:
time.sleep(1)
raise SystemExit('Failed to download: {}'.format(url))
def sw():
sw = os.environ['SW']
os.makedirs(sw)
os.chdir(sw)
url = 'https://download.calibre-ebook.com/travis/win-64.tar.xz'
printf('Downloading', url)
tarball = subprocess.check_output(['curl.exe', '-fsSL', url])
tarball = download_file(url)
with tarfile.open(fileobj=io.BytesIO(tarball)) as tf:
tf.extractall()
printf('Download complete')