working output for py2 and py3. Fix #738

This commit is contained in:
Michel Oosterhof 2018-05-02 14:40:02 +04:00
parent 218da10aa8
commit 7cb8c8930c
1 changed files with 8 additions and 3 deletions

View File

@ -15,6 +15,11 @@ def playlog(fd, settings):
color = None
if sys.version_info >= (3,):
stdout = sys.stdout.buffer
else:
stdout = sys.stdout
while 1:
try:
(op, tty, length, dir, sec, usec) = \
@ -52,10 +57,10 @@ def playlog(fd, settings):
time.sleep(sleeptime)
prevtime = curtime
if settings['colorify'] and color:
sys.stdout.write(color)
sys.stdout.write(data.decode('UTF-8'))
stdout.write(color)
stdout.write(data)
if settings['colorify'] and color:
sys.stdout.write('\033[0m')
stdout.write('\033[0m')
color = None
sys.stdout.flush()
elif str(tty) == str(currtty) and op == OP_CLOSE: