From cee810bf97d6c8ea51eef0749742776a2049e29a Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Wed, 29 Apr 2020 15:45:11 +0100 Subject: [PATCH] simplified run_script() function in tools.py --- perguntations/tools.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/perguntations/tools.py b/perguntations/tools.py index f7e114c..e75663c 100644 --- a/perguntations/tools.py +++ b/perguntations/tools.py @@ -67,21 +67,16 @@ def run_script(script: str, stderr=subprocess.STDOUT, universal_newlines=True, timeout=timeout, - check=False, + check=True, ) - except OSError: - logger.error('Can not execute script "%s".', script) - return output except subprocess.TimeoutExpired: logger.error('Timeout %ds exceeded running "%s".', timeout, script) return output - except Exception: - logger.error('An Exception ocurred running "%s".', script) + except subprocess.CalledProcessError as exc: + logger.error('Return code %d running "%s".', exc.returncode, script) return output - - # --- check return code - if proc.returncode != 0: - logger.error('Return code %d running "%s".', proc.returncode, script) + except OSError: + logger.error('Can not execute script "%s".', script) return output # --- parse yaml -- libgit2 0.21.2