Prevent UnicodeEncodeError
Prevents UnicodeEncodeError: 'ascii' codec can't encode character, while printing shell commands output
This commit is contained in:
parent
cbfeb0a2ea
commit
10f5af82f9
1 changed files with 8 additions and 2 deletions
|
@ -128,9 +128,15 @@ def display(msg, color=None, stderr=False, screen_only=False, log_only=False, ru
|
||||||
msg2 = stringc(msg, color)
|
msg2 = stringc(msg, color)
|
||||||
if not log_only:
|
if not log_only:
|
||||||
if not stderr:
|
if not stderr:
|
||||||
|
try:
|
||||||
print msg2
|
print msg2
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
print msg2.encode('utf-8')
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
print >>sys.stderr, msg2
|
print >>sys.stderr, msg2
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
print >>sys.stderr, msg2.encode('utf-8')
|
||||||
if constants.DEFAULT_LOG_PATH != '':
|
if constants.DEFAULT_LOG_PATH != '':
|
||||||
while msg.startswith("\n"):
|
while msg.startswith("\n"):
|
||||||
msg = msg.replace("\n","")
|
msg = msg.replace("\n","")
|
||||||
|
|
Loading…
Reference in a new issue