Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
d527f28c
Commit
d527f28c
authored
Dec 05, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: exit status changes/hacks for fakessh
parent
ac7a64df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
7 deletions
+49
-7
mitogen/fakessh.py
mitogen/fakessh.py
+34
-5
tests/fakessh_test.py
tests/fakessh_test.py
+15
-2
No files found.
mitogen/fakessh.py
View file @
d527f28c
...
...
@@ -163,12 +163,39 @@ class Process(object):
self
.
stdin
=
mitogen
.
core
.
Sender
(
dest
,
arg
[
1
])
self
.
router
.
broker
.
start_receive
(
self
.
pump
)
if
self
.
proc
:
pmon
=
mitogen
.
master
.
ProcessMonitor
.
instance
()
pmon
.
add
(
self
.
proc
.
pid
,
self
.
_on_proc_exit
)
exitted
=
False
def
_on_exit
(
self
,
msg
,
arg
):
LOG
.
debug
(
'on_exit: proc = %r
'
,
self
.
proc
)
LOG
.
debug
(
'on_exit: proc = %r
, arg = %r'
,
self
.
proc
,
arg
)
if
self
.
proc
:
self
.
proc
.
terminate
()
try
:
self
.
proc
.
terminate
()
except
OSError
:
pass
else
:
self
.
router
.
broker
.
shutdown
()
#self.router.broker.shutdown()
msg
=
(
mitogen
.
core
.
Message
.
pickled
(
(
'sys'
,
None
,
'exit'
,
(
arg
or
0
,),
{}),
handle
=
mitogen
.
core
.
CALL_FUNCTION
,
src_id
=
mitogen
.
parent_ids
[
0
],
dst_id
=
mitogen
.
context_id
,
)
)
print
'HAHA'
print
msg
self
.
router
.
route
(
mitogen
.
core
.
Message
.
pickled
(
(
'sys'
,
None
,
'exit'
,
(
arg
or
0
,),
{}),
handle
=
mitogen
.
core
.
CALL_FUNCTION
,
src_id
=
mitogen
.
parent_ids
[
0
],
dst_id
=
mitogen
.
context_id
,
)
)
def
_on_pump_receive
(
self
,
s
):
IOLOG
.
info
(
'%r._on_pump_receive(len %d)'
,
self
,
len
(
s
))
...
...
@@ -205,8 +232,10 @@ def _start_slave(src_id, cmdline, router):
"""
LOG
.
debug
(
'_start_slave(%r, %r)'
,
router
,
cmdline
)
proc
=
subprocess
.
Popen
(
cmdline
,
# Must be constructed from main thread due to signal use.
pmon
=
mitogen
.
master
.
ProcessMonitor
.
instance
()
proc
=
subprocess
.
Popen
(
cmdline
,
# SSH server always uses user's shell.
shell
=
True
,
# SSH server always executes new commands in the user's HOME.
...
...
tests/fakessh_test.py
View file @
d527f28c
...
...
@@ -9,6 +9,19 @@ import mitogen.fakessh
import
testlib
import
logging
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
class
ExitStatusTest
(
testlib
.
RouterMixin
,
unittest2
.
TestCase
):
# Ensure child's exit status is propagated to the parent.
def
test_exit_0
(
self
):
local
=
self
.
router
.
local
()
exit_status
=
mitogen
.
fakessh
.
run
(
local
,
self
.
router
,
[
'bash'
,
'-c'
,
'exec ssh foo exit 0'
])
self
.
assertEquals
(
0
,
exit_status
)
class
RsyncTest
(
testlib
.
DockerMixin
,
unittest2
.
TestCase
):
def
test_rsync_from_master
(
self
):
context
=
self
.
docker_ssh_any
()
...
...
@@ -17,7 +30,7 @@ class RsyncTest(testlib.DockerMixin, unittest2.TestCase):
context
.
call
(
shutil
.
rmtree
,
'/tmp/data'
)
return_code
=
mitogen
.
fakessh
.
run
(
context
,
self
.
router
,
[
'rsync'
,
'-
-progress'
,
'-vvv
a'
,
'rsync'
,
'-a'
,
testlib
.
data_path
(
'.'
),
'target:/tmp/data'
])
...
...
@@ -49,7 +62,7 @@ class RsyncTest(testlib.DockerMixin, unittest2.TestCase):
webapp_acct
.
call
(
shutil
.
rmtree
,
dest_path
)
return_code
=
pubkey_acct
.
call
(
mitogen
.
fakessh
.
run
,
webapp_acct
,
args
=
[
'rsync'
,
'-
-progress'
,
'-vvv
a'
,
'.ssh/'
,
'target:'
+
dest_path
'rsync'
,
'-a'
,
'.ssh/'
,
'target:'
+
dest_path
])
self
.
assertEqual
(
return_code
,
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