mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-02-28 10:03:38 +01: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
1 changed files with 6 additions and 18 deletions
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import atexit
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
|
@ -16,7 +15,7 @@
|
|||
import time
|
||||
|
||||
from setup import (
|
||||
Command, __appname__, __version__, basenames, download_securely, functions,
|
||||
Command, __appname__, __version__, basenames, functions,
|
||||
isbsd, ishaiku, islinux, modules
|
||||
)
|
||||
|
||||
|
|
@ -356,32 +355,21 @@ def add_options(self, parser):
|
|||
|
||||
def pre_sub_commands(self, opts):
|
||||
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 os.path.exists(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()
|
||||
try:
|
||||
data = download_securely(tarball_url)
|
||||
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))
|
||||
clone_cmd.insert(2, '--depth=1')
|
||||
subprocess.check_call(clone_cmd, cwd=self.d(self.SRC))
|
||||
print('Downloaded translations in %d seconds' % int(time.time() - st))
|
||||
else:
|
||||
if os.path.exists(tdir):
|
||||
subprocess.check_call(['git', 'pull'], cwd=tdir)
|
||||
else:
|
||||
subprocess.check_call([
|
||||
'git', 'clone', 'https://github.com/{}.git'.format(self.TRANSLATIONS_REPO),
|
||||
'translations'], cwd=self.d(self.SRC))
|
||||
subprocess.check_call(clone_cmd, cwd=self.d(self.SRC))
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue