diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
a
|
b
|
|
2 | 2 | import os |
3 | 3 | import sys |
4 | 4 | import glob |
5 | | import warnings |
6 | 5 | from itertools import dropwhile |
7 | 6 | from optparse import make_option |
8 | 7 | from subprocess import PIPE, Popen |
… |
… |
|
36 | 35 | # trick xgettext to parse them as Python files) |
37 | 36 | return set([x for x in ext_list if x != '.py']) |
38 | 37 | |
| 38 | def _popen3(cmd): |
| 39 | p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True) |
| 40 | return p.communicate() |
| 41 | |
39 | 42 | def make_messages(locale=None, domain='django', verbosity='1', all=False, extensions=None): |
40 | 43 | """ |
41 | 44 | Uses the locale directory from the Django SVN tree or an application/ |
… |
… |
|
69 | 72 | raise CommandError(message) |
70 | 73 | |
71 | 74 | # We require gettext version 0.15 or newer. |
72 | | p = Popen('xgettext --version', shell=True, stdout=PIPE, stderr=PIPE) |
73 | | match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', p.stdout.read()) |
| 75 | output = _popen3('xgettext --version')[0] |
| 76 | match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', output) |
74 | 77 | if match: |
75 | 78 | xversion = (int(match.group('major')), int(match.group('minor'))) |
76 | 79 | if xversion < (0, 15): |
… |
… |
|
110 | 113 | thefile = '%s.py' % file |
111 | 114 | open(os.path.join(dirpath, thefile), "w").write(src) |
112 | 115 | cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile)) |
113 | | p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) |
114 | | msgs = p.stdout.read() |
115 | | errors = p.stderr.read() |
| 116 | msgs, errors = _popen3(cmd) |
116 | 117 | if errors: |
117 | 118 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
118 | 119 | old = '#: '+os.path.join(dirpath, thefile)[2:] |
… |
… |
|
140 | 141 | sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) |
141 | 142 | cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % ( |
142 | 143 | domain, os.path.join(dirpath, thefile)) |
143 | | p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) |
144 | | msgs = p.stdout.read() |
145 | | errors = p.stderr.read() |
| 144 | msgs, errors = _popen3(cmd) |
146 | 145 | if errors: |
147 | 146 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
148 | 147 | |
… |
… |
|
161 | 160 | os.unlink(os.path.join(dirpath, thefile)) |
162 | 161 | |
163 | 162 | if os.path.exists(potfile): |
164 | | p = Popen('msguniq --to-code=utf-8 "%s"' % potfile, shell=True, stdout=PIPE, stderr=PIPE) |
165 | | msgs = p.stdout.read() |
166 | | errors = p.stderr.read() |
| 163 | msgs, errors = _popen3('msguniq --to-code=utf-8 "%s"' % potfile) |
167 | 164 | if errors: |
168 | 165 | raise CommandError("errors happened while running msguniq\n%s" % errors) |
169 | 166 | open(potfile, 'w').write(msgs) |
170 | 167 | if os.path.exists(pofile): |
171 | | p = Popen('msgmerge -q "%s" "%s"' % (pofile, potfile), shell=True, stdout=PIPE, stderr=PIPE) |
172 | | msgs = p.stdout.read() |
173 | | errors = p.stderr.read() |
| 168 | msgs, errors = _popen3('msgmerge -q "%s" "%s"' % (pofile, potfile)) |
174 | 169 | if errors: |
175 | 170 | raise CommandError("errors happened while running msgmerge\n%s" % errors) |
176 | 171 | open(pofile, 'wb').write(msgs) |