diff --git a/setup/win-ci.py b/setup/win-ci.py index 32f640025b..690bc38f43 100644 --- a/setup/win-ci.py +++ b/setup/win-ci.py @@ -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')