From a099d2a25ad11519b9f3841210ffcd2a1b414bee Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 27 Nov 2015 18:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=92=AD=E6=94=BEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- connect.py | 4 +++- jlog/log_api.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/connect.py b/connect.py index 4f79fe45d..96418f99d 100644 --- a/connect.py +++ b/connect.py @@ -25,6 +25,7 @@ from jumpserver.api import logger, Log, TtyLog, get_role_key, CRYPTOR from jperm.perm_api import gen_resource, get_group_asset_perm, get_group_user_perm, user_have_perm from jumpserver.settings import LOG_DIR from jperm.ansible_api import Command +from jlog.log_api import escapeString login_user = get_object(User, username=getpass.getuser()) @@ -365,8 +366,9 @@ class SshTty(Tty): self.vim_data += x sys.stdout.write(x) sys.stdout.flush() + es_x = escapeString(x) now_timestamp = time.time() - log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(x))) + log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(es_x))) log_file_f.write(x) pre_timestamp = now_timestamp log_file_f.flush() diff --git a/jlog/log_api.py b/jlog/log_api.py index af6e1418d..578ea684e 100644 --- a/jlog/log_api.py +++ b/jlog/log_api.py @@ -29,7 +29,6 @@ def escapeString(string): string = string.encode('unicode_escape').decode('utf-8', 'ignore') except (UnicodeEncodeError, UnicodeDecodeError): string = string.decode('utf-8', 'ignore') - print repr(string) string = string.replace("'", "\\'") string = '\'' + string + '\'' return string @@ -52,13 +51,14 @@ def scriptToJSON(scriptf, timing=None): for t in timing: dt = scriptf.read(t[1]) data = escapeString(dt) + # print ('###### (%s, %s)' % (t[1], data)) offset += t[0] ret.append((data, offset)) 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)