1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

utils/misc: Ensure outputs are strings when raising exceptions

If the process was killed, either the output or error can
be `None` which causes an error when attempting to join the outputs.
Also update existing error message to prevent 'None' appearing in the error
message.
This commit is contained in:
Marc Bonnici 2018-07-04 17:50:31 +01:00 committed by setrofim
parent 9fd690efb3
commit c4ababcd50

View File

@ -192,9 +192,9 @@ def check_output(command, timeout=None, ignore=None, inputtext=None,
retcode = process.poll()
if retcode:
if retcode == -9: # killed, assume due to timeout callback
raise TimeoutError(command, output='\n'.join([output, error]))
raise TimeoutError(command, output='\n'.join([output or '', error or '']))
elif ignore != 'all' and retcode not in ignore:
raise subprocess.CalledProcessError(retcode, command, output='\n'.join([str(output), str(error)]))
raise subprocess.CalledProcessError(retcode, command, output='\n'.join([output or '', error or '']))
return output, error