summaryrefslogtreecommitdiff
path: root/lib/ansible/utils/display.py
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-07-07 12:05:07 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-07-07 12:05:59 -0700
commit49a148056c86a5ef047a3004a7a0190349adef2b (patch)
tree38dfdbf2c629b46dc55d6469e0be1dddf4fd6d3d /lib/ansible/utils/display.py
parent6d50a261c590c61320c4762b5a5f706cb9620ee5 (diff)
downloadansible-49a148056c86a5ef047a3004a7a0190349adef2b.tar.gz
Ensure that we're dealing with byte str when we print or log messages
Diffstat (limited to 'lib/ansible/utils/display.py')
-rw-r--r--lib/ansible/utils/display.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py
index ab3a06a5ed..a9a4f8bb50 100644
--- a/lib/ansible/utils/display.py
+++ b/lib/ansible/utils/display.py
@@ -28,6 +28,7 @@ import sys
from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.utils.color import stringc
+from ansible.utils.unicode import to_bytes
class Display:
@@ -70,25 +71,21 @@ class Display:
if color:
msg2 = stringc(msg, color)
if not log_only:
+ b_msg2 = to_bytes(msg2)
if not stderr:
- try:
- print(msg2)
- except UnicodeEncodeError:
- print(msg2.encode('utf-8'))
+ print(b_msg2)
else:
- try:
- print(msg2, file=sys.stderr)
- except UnicodeEncodeError:
- print(msg2.encode('utf-8'), file=sys.stderr)
+ print(b_msg2, file=sys.stderr)
if C.DEFAULT_LOG_PATH != '':
while msg.startswith("\n"):
msg = msg.replace("\n","")
+ b_msg = to_bytes(msg)
# FIXME: logger stuff needs to be implemented
#if not screen_only:
# if color == 'red':
- # logger.error(msg)
+ # logger.error(b_msg)
# else:
- # logger.info(msg)
+ # logger.info(b_msg)
def vv(self, msg, host=None):
return self.verbose(msg, host=host, caplevel=1)