summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-02-05 01:26:41 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-05 01:33:48 +0100
commit0a0a3dcf47a65ef29d8c1a9c2280e34c5c2a35e2 (patch)
treee5cf19b7d7c410723191363bbf139c3fa7362e6b
parent0ad7c93a382b673b097bb15b7780d135bcf75668 (diff)
downloadpykolab-0a0a3dcf47a65ef29d8c1a9c2280e34c5c2a35e2.tar.gz
Fix writing unicode output to pipes (#3983)
-rw-r--r--pykolab/cli/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pykolab/cli/__init__.py b/pykolab/cli/__init__.py
index e6ccf0c..56f121b 100644
--- a/pykolab/cli/__init__.py
+++ b/pykolab/cli/__init__.py
@@ -24,6 +24,8 @@ import traceback
import shutil
import sys
import time
+import codecs
+import locale
from ldap.modlist import addModlist
@@ -61,6 +63,9 @@ class Cli(object):
for cmd_component in to_execute:
sys.argv.pop(sys.argv.index(cmd_component.replace('_','-')))
+ # wrap sys.stdout in a locale-aware StreamWriter (#3983)
+ sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
+
commands.execute('_'.join(to_execute))
def run(self):