simpler function for dumping bytes to stdout

This commit is contained in:
Mike McLean 2019-03-01 12:28:11 -05:00
parent 0c2f0ea7c5
commit b4b6e2e6cc
2 changed files with 12 additions and 3 deletions

View file

@ -358,6 +358,15 @@ def write_to_stdout(contents):
contents = bytes.decode(sys.stdout.encoding, 'strict')
sys.stdout.write(contents)
def bytes_to_stdout(contents):
"""Helper function for writing bytes to stdout"""
if six.PY2:
sys.stdout.write(contents)
else:
sys.stdout.buffer.write(contents)
def watch_logs(session, tasklist, opts, poll_interval):
print("Watching logs (this may be safely interrupted)...")
@ -406,7 +415,7 @@ def watch_logs(session, tasklist, opts, poll_interval):
sys.stdout.write("\n")
sys.stdout.write("==> %s <==\n" % currlog)
lastlog = currlog
write_to_stdout(contents)
bytes_to_stdout(contents)
if opts.follow: