mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Prevent UnicodeEncodeError
Prevents UnicodeEncodeError: 'ascii' codec can't encode character, while printing shell commands output
This commit is contained in:
@@ -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","")
|
||||
|
||||
Reference in New Issue
Block a user