diff options
author | Jesusaves <cpntb1@ymail.com> | 2018-03-21 13:56:31 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2018-03-21 13:56:31 -0300 |
commit | d3291401158016c0f6b8c28509b6ca2973952fa4 (patch) | |
tree | a8bc9e9a90f8b46e316b7cc44c753ae3a25d0498 /web | |
parent | 58d049db37ab8cdb91c5b4e03c093ad319b787f6 (diff) | |
download | tools-d3291401158016c0f6b8c28509b6ca2973952fa4.tar.gz tools-d3291401158016c0f6b8c28509b6ca2973952fa4.tar.bz2 tools-d3291401158016c0f6b8c28509b6ca2973952fa4.tar.xz tools-d3291401158016c0f6b8c28509b6ca2973952fa4.zip |
Autofetcher file (for website tools)
Diffstat (limited to 'web')
-rwxr-xr-x | web/fetch.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/web/fetch.py b/web/fetch.py new file mode 100755 index 0000000..5a83fa7 --- /dev/null +++ b/web/fetch.py @@ -0,0 +1,60 @@ +#! /usr/bin/env python2.7 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 TMW-2 +# Author: Jesusalva + +from transifex.api import TransifexAPI +import sys + +if len(sys.argv) == 2: + if sys.argv[1] == "AllFilesVerified": + pass + else: + print("Rejected: Incorrect magic word.") + exit(1) +else: + print("Rejected: As this script is VULNERABLE TO CODE INJECTION, you cannot run this command without verifying all files at Transifex first.") + exit(1) + +project='saulc-tmw-fork' + +print("Loading user credentials (login.txt/password.txt) from lang/ folder...") + +# Load credentials from login.txt and password.txt +login=open('../lang/login.txt', 'r') +for i in login: + username=i.replace('\n', '').replace('\r', '') + +login.close() + +passw=open('../lang/password.txt', 'r') +for i in passw: + password=i.replace('\n', '').replace('\r', '') + +passw.close() + +t=TransifexAPI(username, password, 'https://www.transifex.com') + +if (not t.ping): + print("ERROR: Ping failed, this may be due incorrect username/password in login.txt and password.txt. Ensure there is NO newline at the end of file.") + exit(1) + +if (not t.project_exists(project)): + print("ERROR: Invalid project name") + exit(1) + +# Load languages +langs=[] +vcx=open("langs.txt", "r") +for i in vcx: + if i != "en": + langs.append(i.replace('\n', '')) +vcx.close() + +# Fetch all translations and record them at in/ +for i in langs: + print("Fetching %s..." %(i)) + t.get_translation(project, 'Website', i, 'po/'+str(i)+'.po') + + |