mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Retry sw download on appveyor
This commit is contained in:
parent
7d7fcd312a
commit
8246e539bc
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user