From c6430e246e4e926cfea901923366088e76dcbaac Mon Sep 17 00:00:00 2001 From: Marius Braets Date: Thu, 11 Dec 2025 15:05:09 +0100 Subject: [PATCH] util/helper: add stderr param to ProcessWrapper Signed-off-by: Marius Braets --- labgrid/util/helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/labgrid/util/helper.py b/labgrid/util/helper.py index bc15fd57f..614a4f882 100644 --- a/labgrid/util/helper.py +++ b/labgrid/util/helper.py @@ -40,7 +40,7 @@ class ProcessWrapper: loglevel = logging.INFO @step(args=['command'], result=True, tag='process') - def check_output(self, command, *, print_on_silent_log=False, input=None, stdin=None): # pylint: disable=redefined-builtin + def check_output(self, command, *, print_on_silent_log=False, input=None, stdin=None, stderr=None): # pylint: disable=redefined-builtin """Run a command and supply the output to callback functions""" logger = logging.getLogger("Process") res = [] @@ -58,7 +58,10 @@ def check_output(self, command, *, print_on_silent_log=False, input=None, stdin= elif stdin is not None: kwargs['stdin'] = stdin - process = subprocess.Popen(command, stderr=sfd, + if stderr is None: + stderr = sfd + + process = subprocess.Popen(command, stderr=stderr, stdout=sfd, bufsize=0, **kwargs) logger.log(ProcessWrapper.loglevel, "[%d] command: %s", process.pid, " ".join(command))