Skip to content

Commit

Permalink
Refs #30116 -- Simplified stdout/stderr decoding with subprocess.run(…
Browse files Browse the repository at this point in the history
…)'s encoding argument.

The encoding argument has been available since Python 3.6.
https://docs.python.org/3/library/subprocess.html#subprocess.run
  • Loading branch information
jdufresne authored and felixxm committed Nov 4, 2019
1 parent 5a85666 commit e0e88ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions scripts/manage_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ def lang_stats(resources=None, languages=None):
p = run(
['msgfmt', '-vc', '-o', '/dev/null', po_path],
stdout=PIPE, stderr=PIPE,
env={'LANG': 'C'}
env={'LANG': 'C'},
encoding='utf-8',
)
if p.returncode == 0:
# msgfmt output stats on stderr
print("%s: %s" % (lang, p.stderr.decode().strip()))
print('%s: %s' % (lang, p.stderr.strip()))
else:
print("Errors happened when checking %s translation for %s:\n%s" % (
lang, name, p.stderr.decode()))
print(
'Errors happened when checking %s translation for %s:\n%s'
% (lang, name, p.stderr)
)


def fetch(resources=None, languages=None):
Expand Down
6 changes: 3 additions & 3 deletions tests/postgres_tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_check(self):
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
cwd=os.path.dirname(__file__),
env=test_environ
env=test_environ,
encoding='utf-8',
)
stderr = '\n'.join([e.decode() for e in result.stderr.splitlines()])
self.assertEqual(result.returncode, 0, msg=stderr)
self.assertEqual(result.returncode, 0, msg=result.stderr)

0 comments on commit e0e88ce

Please sign in to comment.