crowdin_sync: Show realtime output of crowdin-cli commands
* Thanks to cybojenix
Change-Id: I13539bdecd5be54a933c05c73eb896a93ce84219
diff --git a/crowdin_sync.py b/crowdin_sync.py
index 2bce4f4..c0a285a 100755
--- a/crowdin_sync.py
+++ b/crowdin_sync.py
@@ -5,7 +5,7 @@
# Updates Crowdin source translations and pushes translations
# directly to CyanogenMod's Gerrit.
#
-# Copyright (C) 2014 The CyanogenMod Project
+# Copyright (C) 2014-2015 The CyanogenMod Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -68,6 +68,13 @@
except:
print('Failed to push commit for ' + name)
+def run_command(cmd):
+ p = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr)
+ ret = p.wait()
+ if ret != 0:
+ print('Failed to run cmd: %s' % ' '.join(cmd))
+ sys.exit(ret)
+
####################################################################################################
parser = argparse.ArgumentParser(description='Synchronising CyanogenMod\'s translations with Crowdin')
@@ -147,11 +154,11 @@
print('\nSTEP 1: Upload Crowdin source translations')
print('Uploading Crowdin source translations (AOSP supported languages)')
# Execute 'crowdin-cli upload sources' and show output
- print(subprocess.check_output(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '.yaml', '--identity=crowdin/config.yaml', 'upload', 'sources']))
+ run_command(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '.yaml', '--identity=crowdin/config.yaml', 'upload', 'sources'])
print('Uploading Crowdin source translations (non-AOSP supported languages)')
# Execute 'crowdin-cli upload sources' and show output
- print(subprocess.check_output(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '_aosp.yaml', '--identity=crowdin/config_aosp.yaml', 'upload', 'sources']))
+ run_command(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '_aosp.yaml', '--identity=crowdin/config_aosp.yaml', 'upload', 'sources'])
else:
print('\nSkipping source translations upload')
@@ -159,11 +166,11 @@
print('\nSTEP 2: Download Crowdin translations')
print('Downloading Crowdin translations (AOSP supported languages)')
# Execute 'crowdin-cli download' and show output
- print(subprocess.check_output(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '.yaml', '--identity=crowdin/config.yaml', 'download']))
+ run_command(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '.yaml', '--identity=crowdin/config.yaml', 'download'])
print('Downloading Crowdin translations (non-AOSP supported languages)')
# Execute 'crowdin-cli download' and show output
- print(subprocess.check_output(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '_aosp.yaml', '--identity=crowdin/config_aosp.yaml', 'download']))
+ run_command(['crowdin-cli', '--config=crowdin/crowdin_' + default_branch + '_aosp.yaml', '--identity=crowdin/config_aosp.yaml', 'download'])
print('\nSTEP 3: Remove useless empty translations')
# Some line of code that I found to find all XML files