Skip to content
Snippets Groups Projects
Commit b5672f15 authored by Bob Lantz's avatar Bob Lantz
Browse files

Cleaning up read/monitor/interrupt.

Now you don't need to specify a default read count.

Now, by default, we print the pid out in sendCmd() which allows us
to snarf it later and set lastPid correctly.

Now, we wrap os.kill() in a try block, so that if the process is
already gone we don't get an exception.
parent de901ef0
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,7 @@ def cleanup( self ):
self.shell = None
# Subshell I/O, commands and control
def read( self, bytes ):
def read( self, bytes=1024 ):
"""Buffered read from node, non-blocking.
bytes: maximum number of bytes to return"""
count = len( self.readbuf )
......@@ -154,7 +154,7 @@ def waitReadable( self ):
if len( self.readbuf ) == 0:
self.pollOut.poll()
def sendCmd( self, cmd, printPid=False ):
def sendCmd( self, cmd, printPid=True ):
"""Send a command, followed by a command to echo a sentinel,
and return without waiting for the command to complete."""
assert not self.waiting
......@@ -175,7 +175,10 @@ def sendCmd( self, cmd, printPid=False ):
def sendInt( self, sig=signal.SIGINT ):
"Interrupt running command."
if self.lastPid:
os.kill( self.lastPid, sig )
try:
os.kill( self.lastPid, sig )
except e, Exception:
pass
def monitor( self ):
"""Monitor and return the output of a command.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment