Skip to content

Commit

Permalink
Exit with a non-zero status code when one or more msgmerge calls fail.
Browse files Browse the repository at this point in the history
Use subprocess instead of os.system.
  • Loading branch information
mgedmin committed Jan 5, 2012
1 parent 4cc7e88 commit c40b5b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ CHANGES
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)
Expand Down
13 changes: 9 additions & 4 deletions src/z3c/recipe/i18n/i18nmergeall.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""
import sys
import os
import subprocess
import getopt

def usage(code, msg=''):
Expand All @@ -46,8 +47,9 @@ def merge(path):
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
Expand All @@ -60,10 +62,13 @@ def merge(path):
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:
Expand Down

0 comments on commit c40b5b7

Please sign in to comment.