From 241ec251a2b2c629f48d060dd50444d1db659d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 23 Jan 2023 14:50:38 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20not=20logging=20individua?= =?UTF-8?q?l=20calls=20on=20CommandlineCaller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/util/commandline.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/octoprint/util/commandline.py b/src/octoprint/util/commandline.py index 67b26ed8f..b6f8c4791 100644 --- a/src/octoprint/util/commandline.py +++ b/src/octoprint/util/commandline.py @@ -161,6 +161,7 @@ class CommandlineCaller: command: Union[str, List[str], Tuple[str]], delimiter: bytes = b"\n", buffer_size: int = -1, + logged: bool = True, **kwargs, ) -> Tuple[Optional[int], List[str], List[str]]: """ @@ -176,7 +177,7 @@ class CommandlineCaller: """ p = self.non_blocking_call( - command, delimiter=delimiter, buffer_size=buffer_size, **kwargs + command, delimiter=delimiter, buffer_size=buffer_size, logged=logged, **kwargs ) if p is None: return None, [], [] @@ -190,7 +191,8 @@ class CommandlineCaller: processed = self._preprocess_lines( *map(lambda x: to_unicode(x, errors="replace"), lines) ) - logger(*processed) + if logged: + logger(*processed) return list(processed) def process_stdout(lines): @@ -218,6 +220,7 @@ class CommandlineCaller: command: Union[str, List, Tuple], delimiter: bytes = b"\n", buffer_size: int = -1, + logged: bool = True, **kwargs, ) -> Optional[sarge.Pipeline]: if isinstance(command, (list, tuple)): @@ -225,7 +228,9 @@ class CommandlineCaller: else: joined_command = command self._logger.debug(f"Calling: {joined_command}") - self.on_log_call(joined_command) + + if logged: + self.on_log_call(joined_command) kwargs.update( {