fix record bug

pull/26/head
ibuler 9 years ago
parent 2c0d42e0da
commit 46245ab4aa

@ -204,7 +204,6 @@ class Tty(object):
log.save()
log_file_f.write('Start at %s\n' % datetime.datetime.now())
log_time_f.write('0.0000 ')
return log_file_f, log_time_f, log
def get_connect_info(self):
@ -326,7 +325,7 @@ class SshTty(Tty):
sys.stdout.write(x)
sys.stdout.flush()
now_timestamp = time.time()
log_time_f.write('%s\n%s ' % (len(x), round(now_timestamp-pre_timestamp, 4)))
log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(x)))
log_file_f.write(x)
pre_timestamp = now_timestamp
log_file_f.flush()
@ -363,7 +362,6 @@ class SshTty(Tty):
finally:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_tty)
log_time_f.write('0')
log_file_f.write('End time is %s' % datetime.datetime.now())
log_file_f.close()
log_time_f.close()

@ -43,14 +43,18 @@ def scriptToJSON(scriptf, timing=None):
scriptf.readline() # ignore first header line from script file
offset = 0
for t in timing:
data = escapeString(scriptf.read(t[1]))
dt = scriptf.read(t[1])
print "## %s: %s" % (t, dt)
data = escapeString(dt)
offset += t[0]
ret.append((data, offset))
print ret
return dumps(ret)
def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatename=DEFAULT_TEMPLATE):
with copen(script_path, encoding='utf-8', errors='replace') as scriptf:
#with copen(script_path, encoding='utf-8', errors='replace') as scriptf:
with open(script_path) as scriptf:
with open(time_file_path) as timef:
timing = getTiming(timef)
json = scriptToJSON(scriptf, timing)

@ -312,7 +312,6 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self.log.is_finished = True
self.log.end_time = datetime.datetime.now()
self.log.save()
self.log_time_f.write('0')
self.log_time_f.close()
self.close()
except AttributeError:
@ -336,7 +335,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
try:
self.write_message(json.dumps({'data': data}))
now_timestamp = time.time()
self.log_time_f.write('%s\n%s ' % (len(data), round(now_timestamp-pre_timestamp, 4)))
self.log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(data)))
self.log_file_f.write(data)
pre_timestamp = now_timestamp
self.log_file_f.flush()

Loading…
Cancel
Save