Commit cee810bf97d6c8ea51eef0749742776a2049e29a
1 parent
bee4a6e0
Exists in
master
and in
1 other branch
simplified run_script() function in tools.py
Showing
1 changed file
with
5 additions
and
10 deletions
Show diff stats
perguntations/tools.py
... | ... | @@ -67,21 +67,16 @@ def run_script(script: str, |
67 | 67 | stderr=subprocess.STDOUT, |
68 | 68 | universal_newlines=True, |
69 | 69 | timeout=timeout, |
70 | - check=False, | |
70 | + check=True, | |
71 | 71 | ) |
72 | - except OSError: | |
73 | - logger.error('Can not execute script "%s".', script) | |
74 | - return output | |
75 | 72 | except subprocess.TimeoutExpired: |
76 | 73 | logger.error('Timeout %ds exceeded running "%s".', timeout, script) |
77 | 74 | return output |
78 | - except Exception: | |
79 | - logger.error('An Exception ocurred running "%s".', script) | |
75 | + except subprocess.CalledProcessError as exc: | |
76 | + logger.error('Return code %d running "%s".', exc.returncode, script) | |
80 | 77 | return output |
81 | - | |
82 | - # --- check return code | |
83 | - if proc.returncode != 0: | |
84 | - logger.error('Return code %d running "%s".', proc.returncode, script) | |
78 | + except OSError: | |
79 | + logger.error('Can not execute script "%s".', script) | |
85 | 80 | return output |
86 | 81 | |
87 | 82 | # --- parse yaml | ... | ... |