summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-20 03:36:20 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-20 03:36:20 -0400
commit88f514c956b304407a2426f3da0918673602e3ee (patch)
treeb73ca57dba966e4eaf71260564f5f109ef882aeb /cmd2/utils.py
parent66faf90bc5551066a207dbd78ad8dd2297f53474 (diff)
downloadcmd2-git-88f514c956b304407a2426f3da0918673602e3ee.tar.gz
Only capturing Popen output when stdout is a StdSim object
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index dd71cfc2..a0026eba 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -371,9 +371,9 @@ class ByteBuf(object):
class ProcReader(object):
- """Used to read stdout and stderr from a process whose stdout and stderr are set to binary pipes"""
- def __init__(self, proc: subprocess.Popen, stdout: Union[BinaryIO, TextIO],
- stderr: Union[BinaryIO, TextIO]) -> None:
+ """Used to read stdout and stderr from a Popen process whose stdout and stderr are set to binary pipes"""
+ def __init__(self, proc: subprocess.Popen, stdout: Union[StdSim, BinaryIO, TextIO],
+ stderr: Union[StdSim, BinaryIO, TextIO]) -> None:
"""
ProcReader initializer
:param proc: the Popen process being read from
@@ -394,6 +394,10 @@ class ProcReader(object):
self._out_thread.start()
self._err_thread.start()
+ def terminate(self) -> None:
+ """Terminates the process being run"""
+ self._proc.terminate()
+
def wait(self) -> None:
"""Wait for the process to finish"""
self._out_thread.join()
@@ -427,7 +431,7 @@ class ProcReader(object):
self._write_bytes(write_stream, available)
@staticmethod
- def _write_bytes(stream: Union[BinaryIO, TextIO], to_write: bytes) -> None:
+ def _write_bytes(stream: Union[StdSim, BinaryIO, TextIO], to_write: bytes) -> None:
"""
Write bytes to a stream
:param stream: the stream being written to