diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-02-04 11:33:34 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-02-04 11:33:34 +0200 |
commit | 34496ac2e519e41750b0140a92dd36d54e010a95 (patch) | |
tree | d995a401d1ca48b2b3ddf319b0357a1d90077240 /yarn | |
parent | 0baa5ca17a70bf83d1b4eab340e7e7c32feb60b1 (diff) | |
download | cmdtest-34496ac2e519e41750b0140a92dd36d54e010a95.tar.gz |
Encode to locale for stdout, stderr; release 0.22cmdtest-0.22
Diffstat (limited to 'yarn')
-rwxr-xr-x | yarn | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -19,6 +19,7 @@ import cliapp import collections +import locale import logging import os import re @@ -106,12 +107,16 @@ class YarnRunner(cliapp.Application): default=False) def stdout(self, msg): - self.output.write(msg) - self.output.flush() + self._write(sys.stdout, msg) def stderr(self, msg): - sys.stderr.write(msg) - sys.stderr.flush() + self._write(sys.stderr, msg) + + def _write(self, output, msg): + if isinstance(msg, unicode): + msg = msg.encode(locale.getpreferredencoding()) + output.write(msg) + output.flush() def info(self, indent, msg): if self.settings['verbose']: |