[Checkins] SVN: z3c.recipe.i18n/trunk/ Exit with a non-zero status code when one or more msgmerge calls fail.

Marius Gedminas marius at pov.lt
Thu Jan 5 21:32:52 UTC 2012


Log message for revision 123960:
  Exit with a non-zero status code when one or more msgmerge calls fail.
  
  Use subprocess instead of os.system.
  
  

Changed:
  U   z3c.recipe.i18n/trunk/CHANGES.txt
  U   z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nmergeall.py

-=-
Modified: z3c.recipe.i18n/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.i18n/trunk/CHANGES.txt	2012-01-05 16:43:01 UTC (rev 123959)
+++ z3c.recipe.i18n/trunk/CHANGES.txt	2012-01-05 21:32:51 UTC (rev 123960)
@@ -5,9 +5,11 @@
 0.8.1 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Exit with a non-zero status code when one or more msgmerge calls fail.
 
+- Use subprocess instead of os.system.
 
+
 0.8.0 (2010-10-07)
 ------------------
 

Modified: z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nmergeall.py
===================================================================
--- z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nmergeall.py	2012-01-05 16:43:01 UTC (rev 123959)
+++ z3c.recipe.i18n/trunk/src/z3c/recipe/i18n/i18nmergeall.py	2012-01-05 21:32:51 UTC (rev 123960)
@@ -30,6 +30,7 @@
 """
 import sys
 import os
+import subprocess
 import getopt
 
 def usage(code, msg=''):
@@ -46,8 +47,9 @@
             break
     domain = pot_name[:-4]
     potPath = os.path.join(path, domain+'.pot')
-    
-    for language in os.listdir(path):
+
+    failed = []
+    for language in sorted(os.listdir(path)):
         lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
 
         # Make sure we got a language directory
@@ -60,10 +62,13 @@
             poFile.write(open(potPath, 'rb').read())
             poFile.close()
 
-        msgs = []
         print 'Merging language "%s", domain "%s"' %(language, domain)
-        os.system('msgmerge -U %s %s' %(poPath, potPath))
+        rc = subprocess.call(['msgmerge', '-U', poPath, potPath])
+        if rc != 0:
+            failed.append(language)
 
+    if failed:
+        sys.exit('msgmerge failed for %s' % ', '.join(failed))
 
 def main(argv=sys.argv):
     try:



More information about the checkins mailing list