shell_command: fix verbosity issue when logging to stderr

In the "run()" method verbosity should still be allowed if log_stderr is True, even
if both callbacks are not set.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-07 11:19:03 -05:00
parent 51fd460b59
commit 22b3a953c5
1 changed files with 5 additions and 3 deletions

View File

@ -68,11 +68,12 @@ class SCProcess(asyncio.subprocess.Process):
stdin = self._feed_stdin(input) stdin = self._feed_stdin(input)
else: else:
stdin = self._noop() stdin = self._noop()
if self.stdout is not None: if self.stdout is not None and self.std_out_cb is not None:
stdout = self._read_stream_with_cb(1) stdout = self._read_stream_with_cb(1)
else: else:
stdout = self._noop() stdout = self._noop()
if self.stderr is not None: has_err_output = self.std_err_cb is not None or self.log_stderr
if self.stderr is not None and has_err_output:
stderr = self._read_stream_with_cb(2) stderr = self._read_stream_with_cb(2)
else: else:
stderr = self._noop() stderr = self._noop()
@ -108,7 +109,8 @@ class ShellCommand:
if not timeout: if not timeout:
# Never timeout # Never timeout
timeout = 9999999999999999. timeout = 9999999999999999.
if self.std_out_cb is None and self.std_err_cb is None: if self.std_out_cb is None and self.std_err_cb is None and \
not self.log_stderr:
# No callbacks set so output cannot be verbose # No callbacks set so output cannot be verbose
verbose = False verbose = False
if not await self._create_subprocess(): if not await self._create_subprocess():