fixed crash on failed command execution

This commit is contained in:
Fredrik Eriksson 2019-05-11 10:14:47 +02:00
parent ec0fe9db5c
commit aa3aef7be0
No known key found for this signature in database
GPG Key ID: 8825C73A0FD1502A

View File

@ -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'))