Ticket #748: make-messages.diff

File make-messages.diff, 2.0 KB (added by hugo, 18 years ago)

patch for better error handling in make-messages.py

  • bin/make-messages.py

     
    7070                if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
    7171                cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
    7272                    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)
    7480                if thefile != file:
    7581                    old = '#: '+os.path.join(dirpath, thefile)[2:]
    7682                    new = '#: '+os.path.join(dirpath, file)[2:]
     
    8086                if thefile != file:
    8187                    os.unlink(os.path.join(dirpath, thefile))
    8288
    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)
    8496    open(potfile, 'w').write(msgs)
    8597    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)
    87105    open(pofile, 'wb').write(msgs)
    88106    os.unlink(potfile)
    89107
Back to Top