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
0707b687
Commit
0707b687
authored
Mar 27, 2016
by
kelianchun_miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect.py use TermLog
parent
445a83f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
connect.py
connect.py
+8
-0
views.py
jlog/views.py
+1
-0
No files found.
connect.py
View file @
0707b687
...
...
@@ -33,6 +33,7 @@ from jumpserver.settings import LOG_DIR
from
jperm.ansible_api
import
MyRunner
# from jlog.log_api import escapeString
from
jlog.models
import
ExecLog
,
FileLog
from
jlog.views
import
TermLogRecorder
login_user
=
get_object
(
User
,
username
=
getpass
.
getuser
())
try
:
...
...
@@ -299,6 +300,8 @@ class SshTty(Tty):
使用paramiko模块的channel,连接后端,进入交互式
"""
log_file_f
,
log_time_f
,
log
=
self
.
get_log
()
termlog
=
TermLogRecorder
(
User
.
objects
.
get
(
id
=
self
.
user
.
id
))
termlog
.
setid
(
log
.
id
)
old_tty
=
termios
.
tcgetattr
(
sys
.
stdin
)
pre_timestamp
=
time
.
time
()
data
=
''
...
...
@@ -335,6 +338,8 @@ class SshTty(Tty):
if
msg
.
errno
==
errno
.
EAGAIN
:
continue
now_timestamp
=
time
.
time
()
termlog
.
write
(
x
)
termlog
.
recoder
=
False
log_time_f
.
write
(
'
%
s
%
s
\n
'
%
(
round
(
now_timestamp
-
pre_timestamp
,
4
),
len
(
x
)))
log_time_f
.
flush
()
log_file_f
.
write
(
x
)
...
...
@@ -355,6 +360,7 @@ class SshTty(Tty):
x
=
os
.
read
(
sys
.
stdin
.
fileno
(),
4096
)
except
OSError
:
pass
termlog
.
recoder
=
True
input_mode
=
True
input_str
+=
x
if
str
(
x
)
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
...
...
@@ -387,6 +393,8 @@ class SshTty(Tty):
log_file_f
.
write
(
'End time is
%
s'
%
datetime
.
datetime
.
now
())
log_file_f
.
close
()
log_time_f
.
close
()
termlog
.
save
()
log
.
log_path
=
termlog
.
filename
log
.
is_finished
=
True
log
.
end_time
=
datetime
.
datetime
.
now
()
log
.
save
()
...
...
jlog/views.py
View file @
0707b687
...
...
@@ -206,6 +206,7 @@ class TermLogRecorder(object):
self
.
commands
=
[]
self
.
_lists
=
None
self
.
file
=
None
self
.
filename
=
None
self
.
_data
=
None
self
.
vim_pattern
=
re
.
compile
(
r'\W?vi[m]?\s.* | \W?fg\s.*'
,
re
.
X
)
self
.
_in_vim
=
False
...
...
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