mirror of https://github.com/jumpserver/jumpserver
中文播放bug
parent
bd885da179
commit
a099d2a25a
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue