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
ef3156e6
Commit
ef3156e6
authored
Mar 04, 2016
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(test): monkey patch
parent
95a7557a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
connect.py
connect.py
+21
-0
No files found.
connect.py
View file @
ef3156e6
...
@@ -32,6 +32,27 @@ from jperm.ansible_api import MyRunner
...
@@ -32,6 +32,27 @@ from jperm.ansible_api import MyRunner
# from jlog.log_api import escapeString
# from jlog.log_api import escapeString
from
jlog.models
import
ExecLog
,
FileLog
from
jlog.models
import
ExecLog
,
FileLog
def
_patched_exec_command
(
self
,
command
,
bufsize
=-
1
,
timeout
=
None
,
get_pty
=
False
,
stdin_binary
=
True
,
stdout_binary
=
False
,
stderr_binary
=
False
):
chan
=
self
.
_transport
.
open_session
()
if
get_pty
:
chan
.
get_pty
()
chan
.
settimeout
(
timeout
)
chan
.
exec_command
(
command
)
stdin
=
chan
.
makefile
(
'wb'
if
stdin_binary
else
'w'
,
bufsize
)
stdout
=
chan
.
makefile
(
'rb'
if
stdin_binary
else
'r'
,
bufsize
)
stderr
=
chan
.
makefile_stderr
(
'rb'
if
stdin_binary
else
'r'
,
bufsize
)
return
stdin
,
stdout
,
stderr
paramiko
.
SSHClient
.
exec_command
=
_patched_exec_command
login_user
=
get_object
(
User
,
username
=
getpass
.
getuser
())
login_user
=
get_object
(
User
,
username
=
getpass
.
getuser
())
try
:
try
:
remote_ip
=
os
.
environ
.
get
(
'SSH_CLIENT'
)
.
split
()[
0
]
remote_ip
=
os
.
environ
.
get
(
'SSH_CLIENT'
)
.
split
()[
0
]
...
...
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