Skip to content

Commit

Permalink
handle py2.7 file redirection issue fix #49
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Dec 10, 2018
1 parent 57d54e0 commit 882ab8b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aliyunlogcli/cli_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ def show_result(result, format_output, decode_output=None):
for encoding in encodings:
try:
if json_fmt:
print(json.dumps(result, sort_keys=True, indent=2, separators=(',', ': '),
encoding=encoding, ensure_ascii=escape))
result = json.dumps(result, sort_keys=True, indent=2, separators=(',', ': '),
encoding=encoding, ensure_ascii=escape)
else:
print(json.dumps(result, sort_keys=True, encoding=encoding, ensure_ascii=escape))
result = json.dumps(result, sort_keys=True, encoding=encoding, ensure_ascii=escape)
if not escape:
# for redirection consideration
print(result.encode('utf8'))
else:
print(result)

break
except UnicodeDecodeError as ex:
Expand Down

0 comments on commit 882ab8b

Please sign in to comment.