handle None in output

This commit is contained in:
Frédéric Péters 2020-04-24 10:35:59 +02:00
parent 30e714bbe5
commit c0d99a7e99
1 changed files with 3 additions and 3 deletions

View File

@ -136,10 +136,10 @@ def output(cmd, print_output=False, exit_on_error=True):
stderr=subprocess.STDOUT,
shell=True)
except subprocess.CalledProcessError as e:
sys.stderr.write(e.output)
if e.output:
sys.stderr.write(e.output.decode('utf-8'))
if exit_on_error:
error(cmd)
if print_output:
print(output)
return output.decode('utf-8')
return output.decode('utf-8') if output else None