Use the new transifex client, which is dog-slow and not API compatible with the old one

Le Sigh.
https://github.com/transifex/cli/issues/5
This commit is contained in:
Kovid Goyal 2022-03-03 12:23:03 +05:30
parent 66f427eef4
commit aec6b7c174
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 28 additions and 7 deletions

View File

@ -27,9 +27,6 @@ jobs:
- name: Install calibre dependencies
run: setup/arch-ci.sh
- name: Install translations dependencies
run: python -m pip install transifex-client
- name: Bootstrap calibre
run: runuser -u ci -- python setup.py bootstrap --ephemeral

View File

@ -37,7 +37,7 @@ class POT(Command): # {{{
kw['cwd'] = kw.get('cwd', self.TRANSLATIONS)
if hasattr(cmd, 'format'):
cmd = shlex.split(cmd)
cmd = ['tx', '--traceback'] + cmd
cmd = [os.environ.get('TX', 'tx')] + cmd
self.info(' '.join(cmd))
return subprocess.check_call(cmd, **kw)
@ -690,7 +690,7 @@ class GetTranslations(Translations): # {{{
if opts.check_for_errors:
self.check_all()
return
self.tx('pull -a --parallel --no-interactive')
self.tx('pull -a')
if not self.is_modified:
self.info('No translations were updated')
return

View File

@ -3,12 +3,16 @@
import glob
import io
import json
import os
import shlex
import subprocess
import sys
import tarfile
import time
from tempfile import NamedTemporaryFile
from urllib.request import urlopen
_plat = sys.platform.lower()
ismacos = 'darwin' in _plat
@ -106,6 +110,23 @@ def install_linux_deps():
run('sudo', 'apt-get', 'install', '-y', 'gettext', 'libgl1-mesa-dev')
def get_tx_tarball_url():
data = json.load(urlopen(
'https://api.github.com/repos/transifex/cli/releases/latest'))
for asset in data['assets']:
if asset['name'] == 'tx-linux-amd64.tar.gz':
return asset['browser_download_url']
def get_tx():
url = get_tx_tarball_url()
print('Downloading:', url)
with urlopen(url) as f:
raw = f.read()
with tarfile.open(fileobj=io.BytesIO(raw), mode='r') as tf:
tf.extract('tx')
def main():
if iswindows:
import runpy
@ -130,16 +151,19 @@ def main():
elif action == 'pot':
transifexrc = '''\
[https://www.transifex.com]
api_hostname = https://api.transifex.com
api_hostname = https://api.transifex.com
rest_hostname = https://rest.api.transifex.com
hostname = https://www.transifex.com
password = PASSWORD
token = PASSWORD
username = api
'''.replace('PASSWORD', os.environ['tx'])
with open(os.path.expanduser('~/.transifexrc'), 'w') as f:
f.write(transifexrc)
install_qt_source_code()
install_env()
run(sys.executable, '-m', 'pip', 'install', 'transifex-client')
get_tx()
os.environ['TX'] = os.path.abspath('tx')
run(sys.executable, 'setup.py', 'pot')
elif action == 'test':
os.environ['CI'] = 'true'