mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Go back to using git to fetch ephemeral translations
No significant speed difference and curl is failing on the macOS Travis VM
This commit is contained in:
parent
a38758ca68
commit
3a688453ab
@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
|||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import glob
|
import glob
|
||||||
import io
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -16,7 +15,7 @@ import textwrap
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from setup import (
|
from setup import (
|
||||||
Command, __appname__, __version__, basenames, download_securely, functions,
|
Command, __appname__, __version__, basenames, functions,
|
||||||
isbsd, ishaiku, islinux, modules
|
isbsd, ishaiku, islinux, modules
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -356,32 +355,21 @@ class Bootstrap(Command):
|
|||||||
|
|
||||||
def pre_sub_commands(self, opts):
|
def pre_sub_commands(self, opts):
|
||||||
tdir = self.j(self.d(self.SRC), 'translations')
|
tdir = self.j(self.d(self.SRC), 'translations')
|
||||||
|
clone_cmd = [
|
||||||
|
'git', 'clone', 'https://github.com/{}.git'.format(self.TRANSLATIONS_REPO), 'translations']
|
||||||
if opts.ephemeral:
|
if opts.ephemeral:
|
||||||
if os.path.exists(tdir):
|
if os.path.exists(tdir):
|
||||||
shutil.rmtree(tdir)
|
shutil.rmtree(tdir)
|
||||||
|
|
||||||
tarball_url = 'https://api.github.com/repos/{}/tarball'.format(self.TRANSLATIONS_REPO)
|
|
||||||
import tarfile
|
|
||||||
self.info('Downloading translations...')
|
|
||||||
st = time.time()
|
st = time.time()
|
||||||
try:
|
clone_cmd.insert(2, '--depth=1')
|
||||||
data = download_securely(tarball_url)
|
subprocess.check_call(clone_cmd, cwd=self.d(self.SRC))
|
||||||
except Exception:
|
|
||||||
time.sleep(1)
|
|
||||||
data = download_securely(tarball_url)
|
|
||||||
tarfile.open(fileobj=io.BytesIO(data)).extractall(tdir)
|
|
||||||
x = os.listdir(tdir)[0]
|
|
||||||
for y in os.listdir(os.path.join(tdir, x)):
|
|
||||||
os.rename(os.path.join(tdir, x, y), os.path.join(tdir, y))
|
|
||||||
os.rmdir(os.path.join(tdir, x))
|
|
||||||
print('Downloaded translations in %d seconds' % int(time.time() - st))
|
print('Downloaded translations in %d seconds' % int(time.time() - st))
|
||||||
else:
|
else:
|
||||||
if os.path.exists(tdir):
|
if os.path.exists(tdir):
|
||||||
subprocess.check_call(['git', 'pull'], cwd=tdir)
|
subprocess.check_call(['git', 'pull'], cwd=tdir)
|
||||||
else:
|
else:
|
||||||
subprocess.check_call([
|
subprocess.check_call(clone_cmd, cwd=self.d(self.SRC))
|
||||||
'git', 'clone', 'https://github.com/{}.git'.format(self.TRANSLATIONS_REPO),
|
|
||||||
'translations'], cwd=self.d(self.SRC))
|
|
||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
self.info('\n\nAll done! You should now be able to run "%s setup.py install" to install calibre' % sys.executable)
|
self.info('\n\nAll done! You should now be able to run "%s setup.py install" to install calibre' % sys.executable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user