Change check_po_status so it fits queerscriptors
parent
9a719d383a
commit
b30f63ebad
|
@ -70,11 +70,11 @@ def get_remote_po():
|
|||
we download a .po file from our translation repo so we can compare it to
|
||||
the new file we have generated after building the website
|
||||
'''
|
||||
po_link = f'https://gitlab.torproject.org/tpo/translation/-/raw/{ BRANCHNAME }/contents+es.po'
|
||||
po_link = f'https://lab.encryptionin.space/Queerscriptors/weblate-website/raw/branch/{ BRANCHNAME }/contents+fr.po'
|
||||
r = requests.get(po_link, allow_redirects=True)
|
||||
try:
|
||||
open('oldcontents+es.po', 'wb').write(r.content)
|
||||
pofile = polib.pofile('oldcontents+es.po')
|
||||
open('oldcontents+fr.po', 'wb').write(r.content)
|
||||
pofile = polib.pofile('oldcontents+fr.po')
|
||||
except OSError:
|
||||
print("Please run me with a lektor-based translation branch, i.e. `../check_po_status.py 'communitytpo-contentspot'`")
|
||||
print("the available branches are: communitytpo-contentspot, support-portal, tbmanual-contentspot, tpo-web, or gettor-website-contentspot")
|
||||
|
@ -84,7 +84,7 @@ def get_remote_po():
|
|||
def get_local_po():
|
||||
''' this is the local file that may have been modified by the build'''
|
||||
try:
|
||||
pofile = polib.pofile('i18n/contents+es.po')
|
||||
pofile = polib.pofile('i18n/contents+fr.po')
|
||||
except OSError:
|
||||
sys.exit("Please run me after building lektor at least once")
|
||||
return pofile
|
||||
|
@ -122,33 +122,10 @@ if stalestrings != []:
|
|||
logging.warning(F'There are {len(stalestrings)} strings in Transifex that are not needed anymore')
|
||||
|
||||
|
||||
os.remove('oldcontents+es.po')
|
||||
|
||||
alert_endpoint = os.environ.get('L10N_ALERT_ENDPOINT')
|
||||
alert_token = os.environ.get('L10N_ALERT_TOKEN')
|
||||
os.remove('oldcontents+fr.po')
|
||||
|
||||
if newstrings != [] or stalestrings != []:
|
||||
if alert_endpoint:
|
||||
CI_JOB_URL = os.environ.get('CI_JOB_URL')
|
||||
CI_JOB_ID = os.environ.get('CI_JOB_ID')
|
||||
HOw_MANY = len(newstrings + stalestrings)
|
||||
alert_payload = { 'title': f'{BRANCHNAME} {HOw_MANY} strings out of sync',
|
||||
'description': f'See details in the job log: {CI_JOB_URL}',
|
||||
'severity': 'info',
|
||||
'fingerprint': BRANCHNAME }
|
||||
alert_auth = {'Authorization': f'Bearer {alert_token}', 'Content-Type': 'application/json'}
|
||||
requests.post(alert_endpoint, json=alert_payload, headers=alert_auth)
|
||||
else:
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
if newstrings == [] and stalestrings == []:
|
||||
if alert_endpoint:
|
||||
from datetime import datetime
|
||||
alert_payload = { 'title': f'{BRANCHNAME} strings out of sync',
|
||||
'severity': 'info',
|
||||
'end_time': datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f'),
|
||||
'fingerprint': BRANCHNAME }
|
||||
alert_auth = {'Authorization': f'Bearer {alert_token}', 'Content-Type': 'application/json'}
|
||||
requests.post(alert_endpoint, json=alert_payload, headers=alert_auth)
|
||||
else:
|
||||
print('strings are synced!')
|
||||
print('strings are synced!')
|
||||
|
|
Loading…
Reference in New Issue