Prevent UnicodeEncodeError

Prevents UnicodeEncodeError: 'ascii' codec can't encode character, while printing shell commands output
pull/5178/head
cavassin 11 years ago
parent cbfeb0a2ea
commit 10f5af82f9

@ -128,9 +128,15 @@ def display(msg, color=None, stderr=False, screen_only=False, log_only=False, ru
msg2 = stringc(msg, color)
if not log_only:
if not stderr:
print msg2
try:
print msg2
except UnicodeEncodeError:
print msg2.encode('utf-8')
else:
print >>sys.stderr, msg2
try:
print >>sys.stderr, msg2
except UnicodeEncodeError:
print >>sys.stderr, msg2.encode('utf-8')
if constants.DEFAULT_LOG_PATH != '':
while msg.startswith("\n"):
msg = msg.replace("\n","")

Loading…
Cancel
Save