mirror of https://github.com/jumpserver/jumpserver
中文播放bug fix
parent
a099d2a25a
commit
117f01e71f
11
connect.py
11
connect.py
|
@ -15,6 +15,7 @@ import readline
|
||||||
import django
|
import django
|
||||||
import paramiko
|
import paramiko
|
||||||
import struct, fcntl, signal, socket, select
|
import struct, fcntl, signal, socket, select
|
||||||
|
from io import open as copen
|
||||||
|
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
||||||
if django.get_version() != '1.6':
|
if django.get_version() != '1.6':
|
||||||
|
@ -225,6 +226,8 @@ class Tty(object):
|
||||||
raise ServerError('Create %s failed, Please modify %s permission.' % (today_connect_log_dir, tty_log_dir))
|
raise ServerError('Create %s failed, Please modify %s permission.' % (today_connect_log_dir, tty_log_dir))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# log_file_f = copen(log_file_path + '.log', mode='at', encoding='utf-8', errors='replace')
|
||||||
|
# log_time_f = copen(log_file_path + '.time', mode='at', encoding='utf-8', errors='replace')
|
||||||
log_file_f = open(log_file_path + '.log', 'a')
|
log_file_f = open(log_file_path + '.log', 'a')
|
||||||
log_time_f = open(log_file_path + '.time', 'a')
|
log_time_f = open(log_file_path + '.time', 'a')
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -245,7 +248,7 @@ class Tty(object):
|
||||||
log.pid = log.id
|
log.pid = log.id
|
||||||
log.save()
|
log.save()
|
||||||
|
|
||||||
log_file_f.write('Start at %s\n' % datetime.datetime.now())
|
log_file_f.write('Start at %s\r\n' % datetime.datetime.now())
|
||||||
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):
|
||||||
|
@ -366,13 +369,13 @@ class SshTty(Tty):
|
||||||
self.vim_data += x
|
self.vim_data += x
|
||||||
sys.stdout.write(x)
|
sys.stdout.write(x)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
es_x = escapeString(x)
|
|
||||||
now_timestamp = time.time()
|
now_timestamp = time.time()
|
||||||
log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(es_x)))
|
log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(x)))
|
||||||
|
log_time_f.flush()
|
||||||
log_file_f.write(x)
|
log_file_f.write(x)
|
||||||
|
log_file_f.flush()
|
||||||
pre_timestamp = now_timestamp
|
pre_timestamp = now_timestamp
|
||||||
log_file_f.flush()
|
log_file_f.flush()
|
||||||
log_time_f.flush()
|
|
||||||
|
|
||||||
if input_mode and not self.is_output(x):
|
if input_mode and not self.is_output(x):
|
||||||
data += x
|
data += x
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from argparse import ArgumentParser, FileType
|
from argparse import ArgumentParser, FileType
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from codecs import open as copen
|
from io import open as copen
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from math import ceil
|
from math import ceil
|
||||||
import re
|
import re
|
||||||
|
@ -46,20 +46,20 @@ def scriptToJSON(scriptf, timing=None):
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
with closing(scriptf):
|
with closing(scriptf):
|
||||||
scriptf.readline() # ignore first header line from script file
|
print "# %s #" % scriptf.readline() # ignore first header line from script file
|
||||||
offset = 0
|
offset = 0
|
||||||
for t in timing:
|
for t in timing:
|
||||||
dt = scriptf.read(t[1])
|
dt = scriptf.read(t[1])
|
||||||
data = escapeString(dt)
|
data = escapeString(dt)
|
||||||
# print ('###### (%s, %s)' % (t[1], data))
|
print ('###### (%s, %s)' % (t[1], repr(data)))
|
||||||
offset += t[0]
|
offset += t[0]
|
||||||
ret.append((data, offset))
|
ret.append((data, offset))
|
||||||
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', newline='\r\n') as scriptf:
|
||||||
with open(script_path) 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)
|
||||||
|
|
Loading…
Reference in New Issue