From 22b3a953c544a360d2f3db4a7a025ef028038ae9 Mon Sep 17 00:00:00 2001 From: Arksine Date: Sun, 7 Mar 2021 11:19:03 -0500 Subject: [PATCH] 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 --- moonraker/plugins/shell_command.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/moonraker/plugins/shell_command.py b/moonraker/plugins/shell_command.py index 607573a..4ce3e52 100644 --- a/moonraker/plugins/shell_command.py +++ b/moonraker/plugins/shell_command.py @@ -68,11 +68,12 @@ class SCProcess(asyncio.subprocess.Process): stdin = self._feed_stdin(input) else: 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) else: 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) else: stderr = self._noop() @@ -108,7 +109,8 @@ class ShellCommand: if not timeout: # Never timeout 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 verbose = False if not await self._create_subprocess():