Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #748 -- Improved error handling in make-messages.py. It no long…

…er clobbers files on error. Thanks, Hugo

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1120 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 290040f7fea4875bc7fbe43c3c05dca5d9debdd0 1 parent c767e0f
Adrian Holovaty authored November 07, 2005

Showing 1 changed file with 21 additions and 3 deletions. Show diff stats Hide diff stats

  1. 24  django/bin/make-messages.py
24  django/bin/make-messages.py
@@ -70,7 +70,13 @@
70 70
                 if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
71 71
                 cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
72 72
                     os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
73  
-                msgs = os.popen(cmd, 'r').read()
  73
+                (stdin, stdout, stderr) = os.popen3(cmd, 'r')
  74
+                msgs = stdout.read()
  75
+                errors = stderr.read()
  76
+                if errors: 
  77
+                    print "errors happened while running xgettext on %s" % file
  78
+                    print errors
  79
+                    sys.exit(8)
74 80
                 if thefile != file:
75 81
                     old = '#: '+os.path.join(dirpath, thefile)[2:]
76 82
                     new = '#: '+os.path.join(dirpath, file)[2:]
@@ -80,10 +86,22 @@
80 86
                 if thefile != file:
81 87
                     os.unlink(os.path.join(dirpath, thefile))
82 88
 
83  
-    msgs = os.popen('msguniq %s' % potfile, 'r').read()
  89
+    (stdin, stdout, stderr) = os.popen3('msguniq %s' % potfile, 'r')
  90
+    msgs = stdout.read()
  91
+    errors = stderr.read()
  92
+    if errors:
  93
+        print "errors happened while running msguniq"
  94
+        print errors
  95
+        sys.exit(8)
84 96
     open(potfile, 'w').write(msgs)
85 97
     if os.path.exists(pofile):
86  
-        msgs = os.popen('msgmerge %s %s' % (pofile, potfile), 'r').read()
  98
+        (stdin, stdout, stderr) = os.popen3('msgmerge -q %s %s' % (pofile, potfile), 'r')
  99
+        msgs = stdout.read()
  100
+        errors = stderr.read()
  101
+        if errors:
  102
+            print "errors happened while running msgmerge"
  103
+            print errors
  104
+            sys.exit(8)
87 105
     open(pofile, 'wb').write(msgs)
88 106
     os.unlink(potfile)
89 107
 

0 notes on commit 290040f

Please sign in to comment.
Something went wrong with that request. Please try again.