Support python 3

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2014-08-19 17:36:46 -04:00
commit 809443d6d0
23 changed files with 128 additions and 85 deletions

View file

@ -1,6 +1,7 @@
import codecs
import json
import os
import six
class StreamOutputError(Exception):
@ -8,8 +9,9 @@ class StreamOutputError(Exception):
def stream_output(output, stream):
is_terminal = hasattr(stream, 'fileno') and os.isatty(stream.fileno())
stream = codecs.getwriter('utf-8')(stream)
is_terminal = hasattr(stream, 'isatty') and stream.isatty()
if not six.PY3:
stream = codecs.getwriter('utf-8')(stream)
all_events = []
lines = {}
diff = 0
@ -55,7 +57,6 @@ def print_output_event(event, stream, is_terminal):
# erase current line
stream.write("%c[2K\r" % 27)
terminator = "\r"
pass
elif 'progressDetail' in event:
return