summaryrefslogtreecommitdiffstats
path: root/pykolab/cli/__init__.py
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:26:41 +0100
commit078a561903078fb83d487891ee86d9ee6f2f0e4e (patch)
treee3e6745f21239c0256c8230942c64de6dc66f6c5 /pykolab/cli/__init__.py
parente94e4e2aac08b92326c1e659d8e3466aa76534a9 (diff)
downloadpykolab-078a561903078fb83d487891ee86d9ee6f2f0e4e.tar.gz
Fix writing unicode output to pipes (#3983)
Diffstat (limited to 'pykolab/cli/__init__.py')
-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):