summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-20 11:16:15 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-20 11:16:15 -0400
commit04b66bb955a456c951b024fe7b1545442fa32c5c (patch)
tree83a78ae517576708589cba28639a45e1cdddbc00 /cmd2/utils.py
parente42065ea805c813790ae91dd00e3677ed811c8cd (diff)
downloadcmd2-git-04b66bb955a456c951b024fe7b1545442fa32c5c.tar.gz
Simiplified code
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 45c7ca6a..d14ef90f 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -371,14 +371,17 @@ class ByteBuf(object):
class ProcReader(object):
- """Used to read stdout and stderr from a Popen process if any of those were set to subprocess.PIPE"""
+ """
+ Used to captured stdout and stderr from a Popen process if any of those were set to subprocess.PIPE.
+ If neither are pipes, then the process will run normally and no output will be captured.
+ """
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
- :param stdout: the stdout stream being written to
- :param stderr: the stderr stream being written to
+ :param stdout: the stream to write captured stdout
+ :param stderr: the stream to write captured stderr
"""
self._proc = proc
self._stdout = stdout
@@ -407,8 +410,8 @@ class ProcReader(object):
if self._err_thread.is_alive():
self._err_thread.join()
- # Handle case where the process ended before the last read could be done
- # This will return None for the streams that weren't pipes so it is safe.
+ # Handle case where the process ended before the last read could be done.
+ # This will return None for the streams that weren't pipes.
out, err = self._proc.communicate()
if out:
self._write_bytes(self._stdout, out)