summaryrefslogtreecommitdiff
path: root/django/bin
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-07 14:21:31 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-07 14:21:31 +0000
commit290040f7fea4875bc7fbe43c3c05dca5d9debdd0 (patch)
treeeb01cbf0e7e0c22a37270125aa0a9a3fd5539950 /django/bin
parentc767e0f4fedabf050a8968b3b2cb68f0183683d7 (diff)
Fixed #748 -- Improved error handling in make-messages.py. It no longer clobbers files on error. Thanks, Hugo
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1120 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/bin')
-rwxr-xr-xdjango/bin/make-messages.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/django/bin/make-messages.py b/django/bin/make-messages.py
index c78faac694..ea4f76b4aa 100755
--- a/django/bin/make-messages.py
+++ b/django/bin/make-messages.py
@@ -70,7 +70,13 @@ for lang in languages:
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
- msgs = os.popen(cmd, 'r').read()
+ (stdin, stdout, stderr) = os.popen3(cmd, 'r')
+ msgs = stdout.read()
+ errors = stderr.read()
+ if errors:
+ print "errors happened while running xgettext on %s" % file
+ print errors
+ sys.exit(8)
if thefile != file:
old = '#: '+os.path.join(dirpath, thefile)[2:]
new = '#: '+os.path.join(dirpath, file)[2:]
@@ -80,10 +86,22 @@ for lang in languages:
if thefile != file:
os.unlink(os.path.join(dirpath, thefile))
- msgs = os.popen('msguniq %s' % potfile, 'r').read()
+ (stdin, stdout, stderr) = os.popen3('msguniq %s' % potfile, 'r')
+ msgs = stdout.read()
+ errors = stderr.read()
+ if errors:
+ print "errors happened while running msguniq"
+ print errors
+ sys.exit(8)
open(potfile, 'w').write(msgs)
if os.path.exists(pofile):
- msgs = os.popen('msgmerge %s %s' % (pofile, potfile), 'r').read()
+ (stdin, stdout, stderr) = os.popen3('msgmerge -q %s %s' % (pofile, potfile), 'r')
+ msgs = stdout.read()
+ errors = stderr.read()
+ if errors:
+ print "errors happened while running msgmerge"
+ print errors
+ sys.exit(8)
open(pofile, 'wb').write(msgs)
os.unlink(potfile)