From 8246e539bcd55c34a655849c4d53da75453f44b3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 9 May 2017 23:05:58 +0530 Subject: [PATCH] Retry sw download on appveyor --- setup/win-ci.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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')