From ceff07de115c0714ac0cd3d2d7ff267039f48b20 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 4 Jul 2019 03:48:21 +0300 Subject: [PATCH 01/12] Add more XBlocks --- edx-platform/xblocks/config.yaml | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/edx-platform/xblocks/config.yaml b/edx-platform/xblocks/config.yaml index 99bc061..cef91d8 100644 --- a/edx-platform/xblocks/config.yaml +++ b/edx-platform/xblocks/config.yaml @@ -19,3 +19,88 @@ xblocks: make push_translations pull_script: | make pull_translations + + - name: xblock-free-text-response + upstream_repo: https://github.com/Stanford-Online/xblock-free-text-response.git + local_repo: git@github.com:OmarIthawi/xblock-free-text-response.git + requirements_script: | + make requirements + push_script: | + make push_translations + pull_script: | + make pull_translations + + - name: xblock-done + upstream_repo: https://github.com/pmitros/DoneXBlock.git + local_repo: git@github.com:pmitros/DoneXBlock.git + requirements_script: | + make requirements + push_script: | + make push_translations + pull_script: | + make pull_translations + + - name: xblock-done + upstream_repo: https://github.com/pmitros/DoneXBlock.git + local_repo: git@github.com:pmitros/DoneXBlock.git + requirements_script: | + make requirements + push_script: | + make push_translations + pull_script: | + make pull_translations + + - name: xblock-lti-consumer + upstream_repo: https://github.com/edx/xblock-lti-consumer.git + local_repo: git@github.com:appsembler/xblock-lti-consumer.git + requirements_script: | + make install + push_script: | + echo "Not supported" + false + pull_script: | + tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP + + - name: xblock-google-drive + upstream_repo: https://github.com/edx-solutions/xblock-google-drive.git + local_repo: git@github.com:appsembler/xblock-google-drive.git + requirements_script: | + make requirements + push_script: | + make push_translations + pull_script: | + make pull_translations + + - name: xblock-pdf + upstream_repo: https://github.com/appsembler/pdfXBlock.git + local_repo: git@github.com:appsembler/pdfXBlock.git + requirements_script: | + make requirements + push_script: | + make push_translations + pull_script: | + make pull_translations + + - name: xblock-ubcpi + upstream_repo: https://github.com/ubc/ubcpi.git + local_repo: git@github.com:appsembler/ubcpi.git + requirements_script: | + make deps + push_script: | + make extract + tx push -s + pull_script: | + tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP + make compile + + - name: xblock-problem-builder + upstream_repo: https://github.com/open-craft/problem-builder.git + local_repo: git@github.com:appsembler/problem-builder.git + requirements_script: | + make requirements + push_script: | + make extract_translations + make push_translations + pull_script: | + make pull_translations + make compile_translations From ccb79d3d273703b6d34d18887e37fa7b58a407ec Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 25 Jul 2019 21:48:11 +0300 Subject: [PATCH 02/12] fixup --- edx-platform/xblocks/xblocks_i18n.py | 71 ++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 89592db..43ee049 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -3,13 +3,27 @@ """ from __future__ import print_function, unicode_literals -from yaml import safe_load +from yaml import safe_load, dump from subprocess import check_call -from os import path +from os import path, walk +from os.path import join, relpath import time XBLOCKS_DIR = path.dirname(__file__) + +def read_prob_files(root): + for parent, dirs, files in walk(root): + for f in files: + if f.endswith('.prob'): + file_path = relpath(join(parent, f), root) + with open(file_path) as file_obj: + yield { + 'path': file_path, + 'content': file_obj.read(), + } + + def xblock_configs(): with open(path.join(XBLOCKS_DIR, 'config.yaml'), 'r') as config_file: config = safe_load(config_file) @@ -23,21 +37,48 @@ def pull_translations(): repos_dir = path.join(XBLOCKS_DIR, 'repos') repo_dir = path.join(repos_dir, config['name']) - branch = 'i18n-bot/{time}'.format(time=time.strftime('%Y-%m-%d-%H%M%S')) - - check_call(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) - check_call(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) - check_call(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) - - check_call(config['requirements_script'], shell=True, cwd=repo_dir) - check_call(config['pull_script'], shell=True, cwd=repo_dir) + try: + branch = 'i18n-bot/{time}'.format(time=time.strftime('%Y-%m-%d-%H%M%S')) + check_call(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) + check_call(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) + check_call(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) + check_call(config['requirements_script'], shell=True, cwd=repo_dir) + except Exception as e: + yield { + 'name': config['name'], + 'stage': 'installation', + 'exception': str(e), + } + continue - check_call(['git', 'config', 'user.name', 'Open edX i18n Bot'], cwd=repo_dir) - check_call(['git', 'config', 'user.email', 'bot-i18n@openedx.org'], cwd=repo_dir) + try: + check_call(config['pull_script'], shell=True, cwd=repo_dir) + except Exception as e: + yield { + 'name': config['name'], + 'stage': 'pull', + 'exception': str(e), + 'prob_files': list(read_prob_files(repo_dir)), + } + continue - check_call(['git', 'add', '--all'], cwd=repo_dir) - check_call(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) + try: + check_call(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) + check_call(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) + check_call(['git', 'add', '--all'], cwd=repo_dir) + check_call(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) + except Exception as e: + yield { + 'name': config['name'], + 'stage': 'commit', + 'exception': str(e), + } + continue if __name__ == '__main__': - pull_translations() + errors = list(pull_translations()) + raise Exception(dump({ + 'description': 'The following errors have happened while pull translations from Transifex', + 'details': errors, + })) From ede0f8907e5275128aaf0bd5161df9bcda858c90 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 25 Jul 2019 22:12:26 +0300 Subject: [PATCH 03/12] fixups --- edx-platform/xblocks/config.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/edx-platform/xblocks/config.yaml b/edx-platform/xblocks/config.yaml index cef91d8..92886f5 100644 --- a/edx-platform/xblocks/config.yaml +++ b/edx-platform/xblocks/config.yaml @@ -40,16 +40,6 @@ xblocks: pull_script: | make pull_translations - - name: xblock-done - upstream_repo: https://github.com/pmitros/DoneXBlock.git - local_repo: git@github.com:pmitros/DoneXBlock.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - name: xblock-lti-consumer upstream_repo: https://github.com/edx/xblock-lti-consumer.git local_repo: git@github.com:appsembler/xblock-lti-consumer.git From d3594daa383d67b391b2dfa039c9dbcd8f95721f Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 25 Jul 2019 22:28:00 +0300 Subject: [PATCH 04/12] fixup --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c07be6e..63b0e15 100644 --- a/Makefile +++ b/Makefile @@ -38,4 +38,4 @@ pull_translations: $(DOCKER_RUN) python xblocks/xblocks_i18n.py make chown find edx-platform/xblocks/repos/ -maxdepth 1 -mindepth 1 -type d \ - -exec bash -c 'cd {} && git push --set-upstream local $(shell rev-parse --abbrev-ref HEAD)' \; + -exec bash -c 'cd {} && git push --set-upstream local $(shell git rev-parse --abbrev-ref HEAD)' \; From 8fd75b0c59246b20bcf6deb103b2039bd7d3391b Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 25 Jul 2019 22:57:57 +0300 Subject: [PATCH 05/12] fixup --- edx-platform/xblocks/xblocks_i18n.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 43ee049..82a2f1c 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -1,11 +1,11 @@ """ Push and pull the latest sources of XBlocks to Transifex in batch. """ -from __future__ import print_function, unicode_literals +from __future__ import print_function -from yaml import safe_load, dump +from yaml import safe_load, safe_dump from subprocess import check_call -from os import path, walk +from os import getenv, path, walk from os.path import join, relpath import time @@ -34,6 +34,10 @@ def xblock_configs(): def pull_translations(): for config in xblock_configs(): + only = getenv('XBLOCK_NAME') + if only and only != config['name']: + continue + repos_dir = path.join(XBLOCKS_DIR, 'repos') repo_dir = path.join(repos_dir, config['name']) @@ -78,7 +82,7 @@ def pull_translations(): if __name__ == '__main__': errors = list(pull_translations()) - raise Exception(dump({ + raise Exception(safe_dump({ 'description': 'The following errors have happened while pull translations from Transifex', 'details': errors, })) From 23f6f54c390c9a0f35bd18807703f6b690b5da0c Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sat, 27 Jul 2019 13:43:04 +0300 Subject: [PATCH 06/12] fixup --- edx-platform/xblocks/xblocks_i18n.py | 44 ++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 82a2f1c..371a52f 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -3,8 +3,9 @@ """ from __future__ import print_function -from yaml import safe_load, safe_dump -from subprocess import check_call +from yaml import safe_load +import json +from subprocess import check_output from os import getenv, path, walk from os.path import join, relpath import time @@ -43,46 +44,65 @@ def pull_translations(): try: branch = 'i18n-bot/{time}'.format(time=time.strftime('%Y-%m-%d-%H%M%S')) - check_call(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) - check_call(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) - check_call(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) - check_call(config['requirements_script'], shell=True, cwd=repo_dir) + check_output(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) + check_output(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) + check_output(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) + check_output(config['requirements_script'], shell=True, cwd=repo_dir) except Exception as e: yield { 'name': config['name'], 'stage': 'installation', 'exception': str(e), + 'output': getattr(e, 'output', ''), } continue try: - check_call(config['pull_script'], shell=True, cwd=repo_dir) + check_output(config['pull_script'], shell=True, cwd=repo_dir) except Exception as e: yield { 'name': config['name'], 'stage': 'pull', 'exception': str(e), + 'output': getattr(e, 'output', ''), 'prob_files': list(read_prob_files(repo_dir)), } continue try: - check_call(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) - check_call(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) - check_call(['git', 'add', '--all'], cwd=repo_dir) - check_call(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) + check_output(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) + check_output(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) + check_output("git add $(find . -name '*.po' -or -name '*.mo' -or -name '*.js')", shell=True, cwd=repo_dir) + check_output(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) except Exception as e: yield { 'name': config['name'], 'stage': 'commit', 'exception': str(e), + 'output': getattr(e, 'output', ''), } continue +def pretty_json(obj): + return json.dumps( + obj, + ensure_ascii=False, + indent=4, + ).replace( + '\\n', '\n' + ).replace( + '\\t', '\t' + ).replace( + '{', '' + ).replace( + '}', '' + ) + + if __name__ == '__main__': errors = list(pull_translations()) - raise Exception(safe_dump({ + raise Exception(pretty_json({ 'description': 'The following errors have happened while pull translations from Transifex', 'details': errors, })) From fdfa8ba2de2951e738a872e1db175f698b477a08 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sat, 27 Jul 2019 16:07:40 +0300 Subject: [PATCH 07/12] fixup --- Makefile | 2 +- edx-platform/xblocks/xblocks_i18n.py | 85 ++++++++-------------------- 2 files changed, 24 insertions(+), 63 deletions(-) diff --git a/Makefile b/Makefile index 63b0e15..9d56185 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ clean: pull_translations: sudo rm -rf edx-platform/xblocks/repos/* - $(DOCKER_RUN) python xblocks/xblocks_i18n.py + $(DOCKER_RUN) bash -c 'pip install ruamel.yaml==0.15.35 && python xblocks/xblocks_i18n.py' make chown find edx-platform/xblocks/repos/ -maxdepth 1 -mindepth 1 -type d \ -exec bash -c 'cd {} && git push --set-upstream local $(shell git rev-parse --abbrev-ref HEAD)' \; diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 371a52f..8659ec5 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -3,9 +3,8 @@ """ from __future__ import print_function -from yaml import safe_load -import json -from subprocess import check_output +from ruamel.yaml import round_trip_load as ruamel_load, dump as ruamel_dump +from subprocess import check_call, CalledProcessError, STDOUT, Popen, call from os import getenv, path, walk from os.path import join, relpath import time @@ -25,9 +24,13 @@ def read_prob_files(root): } +def execute(cmd, **kwargs): + call(cmd, stderr=STDOUT, **kwargs) + + def xblock_configs(): with open(path.join(XBLOCKS_DIR, 'config.yaml'), 'r') as config_file: - config = safe_load(config_file) + config = ruamel_load(config_file) for xblock in config['xblocks']: yield xblock @@ -42,67 +45,25 @@ def pull_translations(): repos_dir = path.join(XBLOCKS_DIR, 'repos') repo_dir = path.join(repos_dir, config['name']) - try: - branch = 'i18n-bot/{time}'.format(time=time.strftime('%Y-%m-%d-%H%M%S')) - check_output(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) - check_output(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) - check_output(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) - check_output(config['requirements_script'], shell=True, cwd=repo_dir) - except Exception as e: - yield { - 'name': config['name'], - 'stage': 'installation', - 'exception': str(e), - 'output': getattr(e, 'output', ''), - } - continue + branch = 'i18n-bot/{time}'.format(time=time.strftime('%Y-%m-%d-%H%M%S')) + execute(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) + # execute(['git', 'clone', config['upstream_repo'], config['name']], cwd=repos_dir) + execute(['git', 'remote', 'add', 'local', config['local_repo']], cwd=repo_dir) + execute(['git', 'checkout', '-b', branch, 'master'], cwd=repo_dir) + execute(config['requirements_script'], shell=True, cwd=repo_dir) try: - check_output(config['pull_script'], shell=True, cwd=repo_dir) - except Exception as e: - yield { - 'name': config['name'], - 'stage': 'pull', - 'exception': str(e), - 'output': getattr(e, 'output', ''), - 'prob_files': list(read_prob_files(repo_dir)), - } - continue - - try: - check_output(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) - check_output(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) - check_output("git add $(find . -name '*.po' -or -name '*.mo' -or -name '*.js')", shell=True, cwd=repo_dir) - check_output(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) - except Exception as e: - yield { - 'name': config['name'], - 'stage': 'commit', - 'exception': str(e), - 'output': getattr(e, 'output', ''), - } - continue - + execute(config['pull_script'], shell=True, cwd=repo_dir) + except CalledProcessError as e: + print('Errors in pulling "{xblock}" resources from Transifex'.format(xblock=config['name'])) + print(ruamel_dump(list(read_prob_files(repo_dir)))) + raise -def pretty_json(obj): - return json.dumps( - obj, - ensure_ascii=False, - indent=4, - ).replace( - '\\n', '\n' - ).replace( - '\\t', '\t' - ).replace( - '{', '' - ).replace( - '}', '' - ) + execute(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) + execute(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) + execute("git add $(find . -name '*.po' -or -name '*.mo' -or -name '*.js')", shell=True, cwd=repo_dir) + execute(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir) if __name__ == '__main__': - errors = list(pull_translations()) - raise Exception(pretty_json({ - 'description': 'The following errors have happened while pull translations from Transifex', - 'details': errors, - })) + pull_translations() From e70b16f3909a5b9afe838658b4ae7c1713905b51 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sat, 27 Jul 2019 16:28:36 +0300 Subject: [PATCH 08/12] fixup --- Makefile | 2 +- edx-platform/xblocks/xblocks_i18n.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9d56185..63b0e15 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ clean: pull_translations: sudo rm -rf edx-platform/xblocks/repos/* - $(DOCKER_RUN) bash -c 'pip install ruamel.yaml==0.15.35 && python xblocks/xblocks_i18n.py' + $(DOCKER_RUN) python xblocks/xblocks_i18n.py make chown find edx-platform/xblocks/repos/ -maxdepth 1 -mindepth 1 -type d \ -exec bash -c 'cd {} && git push --set-upstream local $(shell git rev-parse --abbrev-ref HEAD)' \; diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 8659ec5..e78b5d6 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -3,8 +3,8 @@ """ from __future__ import print_function -from ruamel.yaml import round_trip_load as ruamel_load, dump as ruamel_dump -from subprocess import check_call, CalledProcessError, STDOUT, Popen, call +from yaml import safe_load +from subprocess import CalledProcessError, STDOUT, check_call from os import getenv, path, walk from os.path import join, relpath import time @@ -25,12 +25,12 @@ def read_prob_files(root): def execute(cmd, **kwargs): - call(cmd, stderr=STDOUT, **kwargs) + check_call(cmd, stderr=STDOUT, **kwargs) def xblock_configs(): with open(path.join(XBLOCKS_DIR, 'config.yaml'), 'r') as config_file: - config = ruamel_load(config_file) + config = safe_load(config_file) for xblock in config['xblocks']: yield xblock From 65182a83fa39b2e1bce953ca5dff1d451ece3358 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sat, 27 Jul 2019 16:44:24 +0300 Subject: [PATCH 09/12] fixup --- edx-platform/xblocks/config.yaml | 3 ++- edx-platform/xblocks/xblocks_i18n.py | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/edx-platform/xblocks/config.yaml b/edx-platform/xblocks/config.yaml index 92886f5..10e2f1b 100644 --- a/edx-platform/xblocks/config.yaml +++ b/edx-platform/xblocks/config.yaml @@ -87,7 +87,8 @@ xblocks: upstream_repo: https://github.com/open-craft/problem-builder.git local_repo: git@github.com:appsembler/problem-builder.git requirements_script: | - make requirements + pip install -r requirements.txt + pip install -r requirements-dev.txt push_script: | make extract_translations make push_translations diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index e78b5d6..6473d8b 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -12,16 +12,14 @@ XBLOCKS_DIR = path.dirname(__file__) -def read_prob_files(root): +def print_prob_files(root): for parent, dirs, files in walk(root): for f in files: if f.endswith('.prob'): file_path = relpath(join(parent, f), root) with open(file_path) as file_obj: - yield { - 'path': file_path, - 'content': file_obj.read(), - } + print('=====', file_path, '=====') + print(file_obj.read()) def execute(cmd, **kwargs): @@ -56,7 +54,7 @@ def pull_translations(): execute(config['pull_script'], shell=True, cwd=repo_dir) except CalledProcessError as e: print('Errors in pulling "{xblock}" resources from Transifex'.format(xblock=config['name'])) - print(ruamel_dump(list(read_prob_files(repo_dir)))) + print_prob_files(repo_dir) raise execute(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) From 1f21d743a05cc83e91c6c04bc305871898a15f70 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Sun, 25 Aug 2019 16:49:53 +0300 Subject: [PATCH 10/12] Add ora, plus removed the "xblock" prefix --- edx-platform/xblocks/config.yaml | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/edx-platform/xblocks/config.yaml b/edx-platform/xblocks/config.yaml index 10e2f1b..6d95d51 100644 --- a/edx-platform/xblocks/config.yaml +++ b/edx-platform/xblocks/config.yaml @@ -1,5 +1,5 @@ xblocks: - - name: xblock-poll + - name: poll upstream_repo: https://github.com/open-craft/xblock-poll.git local_repo: git@github.com:appsembler/xblock-poll.git requirements_script: | @@ -9,7 +9,7 @@ xblocks: pull_script: | make pull_translations - - name: xblock-drag-and-drop-v2 + - name: drag-and-drop-v2 upstream_repo: https://github.com/edx-solutions/xblock-drag-and-drop-v2.git local_repo: git@github.com:appsembler/xblock-drag-and-drop-v2.git requirements_script: | @@ -19,8 +19,9 @@ xblocks: make push_translations pull_script: | make pull_translations + make compile_translations - - name: xblock-free-text-response + - name: free-text-response upstream_repo: https://github.com/Stanford-Online/xblock-free-text-response.git local_repo: git@github.com:OmarIthawi/xblock-free-text-response.git requirements_script: | @@ -30,7 +31,7 @@ xblocks: pull_script: | make pull_translations - - name: xblock-done + - name: done upstream_repo: https://github.com/pmitros/DoneXBlock.git local_repo: git@github.com:pmitros/DoneXBlock.git requirements_script: | @@ -40,7 +41,7 @@ xblocks: pull_script: | make pull_translations - - name: xblock-lti-consumer + - name: lti-consumer upstream_repo: https://github.com/edx/xblock-lti-consumer.git local_repo: git@github.com:appsembler/xblock-lti-consumer.git requirements_script: | @@ -51,7 +52,7 @@ xblocks: pull_script: | tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP - - name: xblock-google-drive + - name: google-drive upstream_repo: https://github.com/edx-solutions/xblock-google-drive.git local_repo: git@github.com:appsembler/xblock-google-drive.git requirements_script: | @@ -61,7 +62,7 @@ xblocks: pull_script: | make pull_translations - - name: xblock-pdf + - name: pdf upstream_repo: https://github.com/appsembler/pdfXBlock.git local_repo: git@github.com:appsembler/pdfXBlock.git requirements_script: | @@ -71,7 +72,7 @@ xblocks: pull_script: | make pull_translations - - name: xblock-ubcpi + - name: ubcpi upstream_repo: https://github.com/ubc/ubcpi.git local_repo: git@github.com:appsembler/ubcpi.git requirements_script: | @@ -83,7 +84,7 @@ xblocks: tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP make compile - - name: xblock-problem-builder + - name: problem-builder upstream_repo: https://github.com/open-craft/problem-builder.git local_repo: git@github.com:appsembler/problem-builder.git requirements_script: | @@ -95,3 +96,15 @@ xblocks: pull_script: | make pull_translations make compile_translations + + - name: ora2 + upstream_repo: https://github.com/edx/edx-ora2.git + local_repo: git@github.com:appsembler/edx-ora2.git + requirements_script: | + make install + push_script: | + make extract_translations + make push_translations + pull_script: | + tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP --minimum-perc=1 + make compile_translations From 9203c95ced01824eb2540ab89cc91debeaa5c8ee Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Mon, 26 Aug 2019 11:45:28 +0300 Subject: [PATCH 11/12] Switch to JSON for broader Python compatibility --- edx-platform/xblocks/config.json | 84 ++++++++++++++++++++ edx-platform/xblocks/config.yaml | 110 --------------------------- edx-platform/xblocks/xblocks_i18n.py | 6 +- 3 files changed, 87 insertions(+), 113 deletions(-) create mode 100644 edx-platform/xblocks/config.json delete mode 100644 edx-platform/xblocks/config.yaml diff --git a/edx-platform/xblocks/config.json b/edx-platform/xblocks/config.json new file mode 100644 index 0000000..80fc8a5 --- /dev/null +++ b/edx-platform/xblocks/config.json @@ -0,0 +1,84 @@ +{ + "xblocks": [ + { + "name": "poll", + "upstream_repo": "https://github.com/open-craft/xblock-poll.git", + "local_repo": "git@github.com:appsembler/xblock-poll.git", + "requirements_script": "make requirements", + "push_script": "make push_translations", + "pull_script": "make pull_translations" + }, + { + "name": "drag-and-drop-v2", + "upstream_repo": "https://github.com/edx-solutions/xblock-drag-and-drop-v2.git", + "local_repo": "git@github.com:appsembler/xblock-drag-and-drop-v2.git", + "requirements_script": "pip install -r requirements.txt", + "push_script": "make extract_translations && make push_translations", + "pull_script": "make pull_translations && make compile_translations" + }, + { + "name": "free-text-response", + "upstream_repo": "https://github.com/Stanford-Online/xblock-free-text-response.git", + "local_repo": "git@github.com:OmarIthawi/xblock-free-text-response.git", + "requirements_script": "make requirements", + "push_script": "make push_translations", + "pull_script": "make pull_translations" + }, + { + "name": "done", + "upstream_repo": "https://github.com/pmitros/DoneXBlock.git", + "local_repo": "git@github.com:pmitros/DoneXBlock.git", + "requirements_script": "make requirements", + "push_script": "make push_translations", + "pull_script": "make pull_translations" + }, + { + "name": "lti-consumer", + "upstream_repo": "https://github.com/edx/xblock-lti-consumer.git", + "local_repo": "git@github.com:appsembler/xblock-lti-consumer.git", + "requirements_script": "make install", + "push_script": "echo 'Not supported' && false", + "pull_script": "tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP" + }, + { + "name": "google-drive", + "upstream_repo": "https://github.com/edx-solutions/xblock-google-drive.git", + "local_repo": "git@github.com:appsembler/xblock-google-drive.git", + "requirements_script": "make requirements", + "push_script": "make push_translations", + "pull_script": "make pull_translations" + }, + { + "name": "pdf", + "upstream_repo": "https://github.com/appsembler/pdfXBlock.git", + "local_repo": "git@github.com:appsembler/pdfXBlock.git", + "requirements_script": "make requirements", + "push_script": "make push_translations", + "pull_script": "make pull_translations" + }, + { + "name": "ubcpi", + "upstream_repo": "https://github.com/ubc/ubcpi.git", + "local_repo": "git@github.com:appsembler/ubcpi.git", + "requirements_script": "make deps", + "push_script": "make extract && tx push -s", + "pull_script": "tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP && make compile" + }, + { + "name": "problem-builder", + "upstream_repo": "https://github.com/open-craft/problem-builder.git", + "local_repo": "git@github.com:appsembler/problem-builder.git", + "requirements_script": "pip install -r requirements.txt && pip install -r requirements-dev.txt", + "push_script": "make extract_translations && make push_translations", + "pull_script": "make pull_translations && make compile_translations" + }, + { + "name": "ora2", + "upstream_repo": "https://github.com/edx/edx-ora2.git", + "local_repo": "git@github.com:appsembler/edx-ora2.git", + "requirements_script": "make install", + "push_script": "make extract_translations && make push_translations", + "pull_script": "tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP --minimum-perc=1 && make compile_translations" + } + ] +} \ No newline at end of file diff --git a/edx-platform/xblocks/config.yaml b/edx-platform/xblocks/config.yaml deleted file mode 100644 index 6d95d51..0000000 --- a/edx-platform/xblocks/config.yaml +++ /dev/null @@ -1,110 +0,0 @@ -xblocks: - - name: poll - upstream_repo: https://github.com/open-craft/xblock-poll.git - local_repo: git@github.com:appsembler/xblock-poll.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - - name: drag-and-drop-v2 - upstream_repo: https://github.com/edx-solutions/xblock-drag-and-drop-v2.git - local_repo: git@github.com:appsembler/xblock-drag-and-drop-v2.git - requirements_script: | - pip install -r requirements.txt - push_script: | - make extract_translations - make push_translations - pull_script: | - make pull_translations - make compile_translations - - - name: free-text-response - upstream_repo: https://github.com/Stanford-Online/xblock-free-text-response.git - local_repo: git@github.com:OmarIthawi/xblock-free-text-response.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - - name: done - upstream_repo: https://github.com/pmitros/DoneXBlock.git - local_repo: git@github.com:pmitros/DoneXBlock.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - - name: lti-consumer - upstream_repo: https://github.com/edx/xblock-lti-consumer.git - local_repo: git@github.com:appsembler/xblock-lti-consumer.git - requirements_script: | - make install - push_script: | - echo "Not supported" - false - pull_script: | - tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP - - - name: google-drive - upstream_repo: https://github.com/edx-solutions/xblock-google-drive.git - local_repo: git@github.com:appsembler/xblock-google-drive.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - - name: pdf - upstream_repo: https://github.com/appsembler/pdfXBlock.git - local_repo: git@github.com:appsembler/pdfXBlock.git - requirements_script: | - make requirements - push_script: | - make push_translations - pull_script: | - make pull_translations - - - name: ubcpi - upstream_repo: https://github.com/ubc/ubcpi.git - local_repo: git@github.com:appsembler/ubcpi.git - requirements_script: | - make deps - push_script: | - make extract - tx push -s - pull_script: | - tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP - make compile - - - name: problem-builder - upstream_repo: https://github.com/open-craft/problem-builder.git - local_repo: git@github.com:appsembler/problem-builder.git - requirements_script: | - pip install -r requirements.txt - pip install -r requirements-dev.txt - push_script: | - make extract_translations - make push_translations - pull_script: | - make pull_translations - make compile_translations - - - name: ora2 - upstream_repo: https://github.com/edx/edx-ora2.git - local_repo: git@github.com:appsembler/edx-ora2.git - requirements_script: | - make install - push_script: | - make extract_translations - make push_translations - pull_script: | - tx pull -f --mode=reviewed -l en,ar,es_419,fr,fr_CA,he,hi,ko_KR,pt_BR,ru,zh_CN,ja_JP --minimum-perc=1 - make compile_translations diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index 6473d8b..b9aaa9c 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -3,7 +3,7 @@ """ from __future__ import print_function -from yaml import safe_load +from json import load from subprocess import CalledProcessError, STDOUT, check_call from os import getenv, path, walk from os.path import join, relpath @@ -27,8 +27,8 @@ def execute(cmd, **kwargs): def xblock_configs(): - with open(path.join(XBLOCKS_DIR, 'config.yaml'), 'r') as config_file: - config = safe_load(config_file) + with open(path.join(XBLOCKS_DIR, 'config.json'), 'r') as config_file: + config = load(config_file) for xblock in config['xblocks']: yield xblock From ae123d4f7f8efb6e839554fce408372bc0f20c4d Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Wed, 28 Aug 2019 19:10:43 +0300 Subject: [PATCH 12/12] More stable git add --- edx-platform/xblocks/xblocks_i18n.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edx-platform/xblocks/xblocks_i18n.py b/edx-platform/xblocks/xblocks_i18n.py index b9aaa9c..2ed1376 100644 --- a/edx-platform/xblocks/xblocks_i18n.py +++ b/edx-platform/xblocks/xblocks_i18n.py @@ -59,7 +59,8 @@ def pull_translations(): execute(['git', 'config', 'user.name', 'Omar Al-Ithawi'], cwd=repo_dir) execute(['git', 'config', 'user.email', 'i@omardo.com'], cwd=repo_dir) - execute("git add $(find . -name '*.po' -or -name '*.mo' -or -name '*.js')", shell=True, cwd=repo_dir) + execute("git add $(git status --porcelain --untracked-files=all | " + "grep -e '\\.po' -e '\\.mo$' -e '\\.js$' | cut -c4-)", shell=True, cwd=repo_dir) execute(['git', 'commit', '-m', 'Update translations (autogenerated message)'], cwd=repo_dir)