From 891829a4abd145bc5b0a5df36546b7458f083c8c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 15 Oct 2020 16:05:15 +0200 Subject: [PATCH] stdout and stderr are logged at once to logger --- pype/lib.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/pype/lib.py b/pype/lib.py index 0f19a68ae6..978386af3a 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -101,19 +101,14 @@ def _subprocess(*args, logger=None, **kwargs): proc = subprocess.Popen(*args, **kwargs) - output, error = proc.communicate() + _stdout, _stderr = proc.communicate() + if _stdout: + _stdout = _stdout.decode("utf-8") + logger.debug(_stdout) - if output: - output = output.decode("utf-8") - output += "\n" - for line in output.strip().split("\n"): - log.info(line) - - if error: - error = error.decode("utf-8") - error += "\n" - for line in error.strip().split("\n"): - log.error(line) + if _stderr: + _stderr = _stderr.decode("utf-8") + logger.warning(_stderr) if proc.returncode != 0: raise ValueError(