mirror of https://github.com/cowrie/cowrie.git
working output for py2 and py3. Fix #738
This commit is contained in:
parent
218da10aa8
commit
7cb8c8930c
11
bin/playlog
11
bin/playlog
|
@ -15,6 +15,11 @@ def playlog(fd, settings):
|
||||||
|
|
||||||
color = None
|
color = None
|
||||||
|
|
||||||
|
if sys.version_info >= (3,):
|
||||||
|
stdout = sys.stdout.buffer
|
||||||
|
else:
|
||||||
|
stdout = sys.stdout
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
(op, tty, length, dir, sec, usec) = \
|
(op, tty, length, dir, sec, usec) = \
|
||||||
|
@ -52,10 +57,10 @@ def playlog(fd, settings):
|
||||||
time.sleep(sleeptime)
|
time.sleep(sleeptime)
|
||||||
prevtime = curtime
|
prevtime = curtime
|
||||||
if settings['colorify'] and color:
|
if settings['colorify'] and color:
|
||||||
sys.stdout.write(color)
|
stdout.write(color)
|
||||||
sys.stdout.write(data.decode('UTF-8'))
|
stdout.write(data)
|
||||||
if settings['colorify'] and color:
|
if settings['colorify'] and color:
|
||||||
sys.stdout.write('\033[0m')
|
stdout.write('\033[0m')
|
||||||
color = None
|
color = None
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
elif str(tty) == str(currtty) and op == OP_CLOSE:
|
elif str(tty) == str(currtty) and op == OP_CLOSE:
|
||||||
|
|
Loading…
Reference in New Issue