2015-05-08 17:27:58 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# ACE3 automatic deployment script #
|
|
|
|
# ================================ #
|
|
|
|
# This is not meant to be run #
|
2020-06-15 15:11:45 +00:00
|
|
|
# directly!! #
|
2015-05-08 17:27:58 +00:00
|
|
|
####################################
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import traceback
|
|
|
|
import subprocess as sp
|
2023-04-30 21:03:35 +00:00
|
|
|
from github import Github
|
2015-05-08 17:27:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
TRANSLATIONISSUE = 367
|
2022-04-14 07:22:23 +00:00
|
|
|
TRANSLATIONBODY = """**[ACE3 Translation Guide](http://ace3.acemod.org/wiki/development/how-to-translate-ace3.html)**
|
2015-05-08 17:27:58 +00:00
|
|
|
|
|
|
|
{}
|
|
|
|
"""
|
|
|
|
|
|
|
|
REPOUSER = "acemod"
|
|
|
|
REPONAME = "ACE3"
|
2023-04-30 21:03:35 +00:00
|
|
|
REPOPATH = "{}/{}".format(REPOUSER, REPONAME)
|
2015-05-08 17:27:58 +00:00
|
|
|
|
2019-10-05 20:56:41 +00:00
|
|
|
BRANCH = "master"
|
|
|
|
|
2015-05-08 17:27:58 +00:00
|
|
|
|
2016-08-19 14:12:09 +00:00
|
|
|
def update_translations(repo):
|
2015-05-08 17:27:58 +00:00
|
|
|
diag = sp.check_output(["python3", "tools/stringtablediag.py", "--markdown"])
|
|
|
|
diag = str(diag, "utf-8")
|
|
|
|
issue = repo.get_issue(TRANSLATIONISSUE)
|
|
|
|
issue.edit(body=TRANSLATIONBODY.format(diag))
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
print("Obtaining token ...")
|
|
|
|
try:
|
|
|
|
token = os.environ["GH_TOKEN"]
|
2016-08-19 14:12:09 +00:00
|
|
|
repo = Github(token).get_repo(REPOPATH)
|
2015-05-08 17:27:58 +00:00
|
|
|
except:
|
|
|
|
print("Could not obtain token.")
|
|
|
|
print(traceback.format_exc())
|
|
|
|
return 1
|
|
|
|
else:
|
2016-08-19 14:12:09 +00:00
|
|
|
print("Token sucessfully obtained.")
|
2015-05-08 17:27:58 +00:00
|
|
|
|
|
|
|
print("\nUpdating translation issue ...")
|
|
|
|
try:
|
2016-08-19 14:12:09 +00:00
|
|
|
update_translations(repo)
|
2015-05-08 17:27:58 +00:00
|
|
|
except:
|
|
|
|
print("Failed to update translation issue.")
|
|
|
|
print(traceback.format_exc())
|
|
|
|
return 1
|
|
|
|
else:
|
2016-08-19 14:12:09 +00:00
|
|
|
print("Translation issue successfully updated.")
|
|
|
|
|
2015-05-08 17:27:58 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|