From 04b66bb955a456c951b024fe7b1545442fa32c5c Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Wed, 20 Mar 2019 11:16:15 -0400 Subject: Simiplified code --- cmd2/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cmd2/utils.py') 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) -- cgit v1.2.1