Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
117f01e7
Commit
117f01e7
authored
Nov 28, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
中文播放bug fix
parent
a099d2a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
connect.py
connect.py
+7
-4
log_api.py
jlog/log_api.py
+5
-5
No files found.
connect.py
View file @
117f01e7
...
...
@@ -15,6 +15,7 @@ import readline
import
django
import
paramiko
import
struct
,
fcntl
,
signal
,
socket
,
select
from
io
import
open
as
copen
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'jumpserver.settings'
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
))
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_time_f
=
open
(
log_file_path
+
'.time'
,
'a'
)
except
IOError
:
...
...
@@ -245,7 +248,7 @@ class Tty(object):
log
.
pid
=
log
.
id
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
def
get_connect_info
(
self
):
...
...
@@ -366,13 +369,13 @@ 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
(
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
.
flush
()
pre_timestamp
=
now_timestamp
log_file_f
.
flush
()
log_time_f
.
flush
()
if
input_mode
and
not
self
.
is_output
(
x
):
data
+=
x
...
...
jlog/log_api.py
View file @
117f01e7
...
...
@@ -3,7 +3,7 @@
from
argparse
import
ArgumentParser
,
FileType
from
contextlib
import
closing
from
codecs
import
open
as
copen
from
io
import
open
as
copen
from
json
import
dumps
from
math
import
ceil
import
re
...
...
@@ -46,20 +46,20 @@ def scriptToJSON(scriptf, timing=None):
ret
=
[]
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
for
t
in
timing
:
dt
=
scriptf
.
read
(
t
[
1
])
data
=
escapeString
(
dt
)
# print ('###### (%s, %s)' % (t[1], data
))
print
(
'###### (
%
s,
%
s)'
%
(
t
[
1
],
repr
(
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
open
(
script_path
)
as
scriptf
:
with
copen
(
script_path
,
encoding
=
'utf-8'
,
errors
=
'replace'
,
newline
=
'
\r\n
'
)
as
scriptf
:
#
with open(script_path) as scriptf:
with
open
(
time_file_path
)
as
timef
:
timing
=
getTiming
(
timef
)
json
=
scriptToJSON
(
scriptf
,
timing
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment