From 37966dc3b4d7762092d50819156fd1f0f256715d Mon Sep 17 00:00:00 2001 From: Sergio Date: Fri, 27 Sep 2024 23:02:29 +0200 Subject: [PATCH] @ktf suggestions --- alibuild_helpers/cmd.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/alibuild_helpers/cmd.py b/alibuild_helpers/cmd.py index 9c8e3c82..a0ea2db5 100644 --- a/alibuild_helpers/cmd.py +++ b/alibuild_helpers/cmd.py @@ -8,10 +8,6 @@ from alibuild_helpers.log import debug, warning, dieOnError -def is_string(s): - return isinstance(s, str) - - def decode_with_fallback(data): """Try to decode DATA as utf-8; if that doesn't work, fall back to latin-1. @@ -29,7 +25,7 @@ def decode_with_fallback(data): def getoutput(command, timeout=None): """Run command, check it succeeded, and return its stdout as a string.""" - proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=PIPE) + proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=PIPE) try: stdout, stderr = proc.communicate(timeout=timeout) except TimeoutExpired: @@ -43,7 +39,7 @@ def getoutput(command, timeout=None): def getstatusoutput(command, timeout=None): """Run command and return its return code and output (stdout and stderr).""" - proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT) + proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT) try: merged_output, _ = proc.communicate(timeout=timeout) except TimeoutExpired: @@ -59,7 +55,7 @@ def getstatusoutput(command, timeout=None): def execute(command, printer=debug, timeout=None): - popen = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT) + popen = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT) start_time = time.time() for line in iter(popen.stdout.readline, b""): printer("%s", decode_with_fallback(line).strip("\n"))