From aa3aef7be0f77235b42352f16a4f9e849f90be4c Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sat, 11 May 2019 10:14:47 +0200 Subject: [PATCH] fixed crash on failed command execution --- sau/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sau/helpers.py b/sau/helpers.py index 8f2c551..0125917 100644 --- a/sau/helpers.py +++ b/sau/helpers.py @@ -12,6 +12,9 @@ def exec_cmd(cmd, timeout=900, env = None): stdout=subprocess.PIPE, stderr=subprocess.PIPE, env = env) + out = b"" + err = b"" + try: out, err = proc.communicate(timeout=timeout) except subprocess.TimeoutExpired as err: @@ -22,7 +25,6 @@ def exec_cmd(cmd, timeout=900, env = None): log.error('Command "{}" would not be killed, forcing a termination'.format(' '.join(cmd))) proc.terminate() time.sleep(5) - return (proc.returncode, out.decode('utf-8'), err.decode('utf-8'))