fix record bug

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

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

@ -43,14 +43,18 @@ def scriptToJSON(scriptf, timing=None):
scriptf.readline() # ignore first header line from script file scriptf.readline() # ignore first header line from script file
offset = 0 offset = 0
for t in timing: 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] offset += t[0]
ret.append((data, offset)) ret.append((data, offset))
print ret
return dumps(ret) return dumps(ret)
def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatename=DEFAULT_TEMPLATE): 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: with open(time_file_path) as timef:
timing = getTiming(timef) timing = getTiming(timef)
json = scriptToJSON(scriptf, timing) json = scriptToJSON(scriptf, timing)

@ -312,7 +312,6 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self.log.is_finished = True self.log.is_finished = True
self.log.end_time = datetime.datetime.now() self.log.end_time = datetime.datetime.now()
self.log.save() self.log.save()
self.log_time_f.write('0')
self.log_time_f.close() self.log_time_f.close()
self.close() self.close()
except AttributeError: except AttributeError:
@ -336,7 +335,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
try: try:
self.write_message(json.dumps({'data': data})) self.write_message(json.dumps({'data': data}))
now_timestamp = time.time() 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) self.log_file_f.write(data)
pre_timestamp = now_timestamp pre_timestamp = now_timestamp
self.log_file_f.flush() self.log_file_f.flush()

Loading…
Cancel
Save