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 subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _winreg as winreg
|
import _winreg as winreg
|
||||||
@ -159,13 +160,22 @@ def printf(*args, **kw):
|
|||||||
sys.stdout.flush()
|
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():
|
def sw():
|
||||||
sw = os.environ['SW']
|
sw = os.environ['SW']
|
||||||
os.makedirs(sw)
|
os.makedirs(sw)
|
||||||
os.chdir(sw)
|
os.chdir(sw)
|
||||||
url = 'https://download.calibre-ebook.com/travis/win-64.tar.xz'
|
url = 'https://download.calibre-ebook.com/travis/win-64.tar.xz'
|
||||||
printf('Downloading', url)
|
tarball = download_file(url)
|
||||||
tarball = subprocess.check_output(['curl.exe', '-fsSL', url])
|
|
||||||
with tarfile.open(fileobj=io.BytesIO(tarball)) as tf:
|
with tarfile.open(fileobj=io.BytesIO(tarball)) as tf:
|
||||||
tf.extractall()
|
tf.extractall()
|
||||||
printf('Download complete')
|
printf('Download complete')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user