mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-23 12:21:54 +01:00
devlib: Replace errors when decoding output from subprocess
If an error occurs when attempting to decode the output from subprocess replace the offending character rather than raising an error.
This commit is contained in:
@@ -153,7 +153,7 @@ class ApkInfo(object):
|
||||
try:
|
||||
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
|
||||
if sys.version_info[0] == 3:
|
||||
output = output.decode(sys.stdout.encoding)
|
||||
output = output.decode(sys.stdout.encoding, 'replace')
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise HostError('Error parsing APK file {}. `aapt` says:\n{}'
|
||||
.format(apk_path, e.output))
|
||||
|
@@ -265,7 +265,7 @@ class SshConnection(object):
|
||||
# the regex removes line breaks potential introduced when writing
|
||||
# command to shell.
|
||||
if sys.version_info[0] == 3:
|
||||
output = process_backspaces(self.conn.before.decode(sys.stdout.encoding))
|
||||
output = process_backspaces(self.conn.before.decode(sys.stdout.encoding, 'replace'))
|
||||
else:
|
||||
output = process_backspaces(self.conn.before)
|
||||
output = re.sub(r'\r([^\n])', r'\1', output)
|
||||
|
@@ -10,6 +10,6 @@ def get_commit():
|
||||
if p.returncode:
|
||||
return None
|
||||
if sys.version_info[0] == 3:
|
||||
return std[:8].decode(sys.stdout.encoding)
|
||||
return std[:8].decode(sys.stdout.encoding, 'replace')
|
||||
else:
|
||||
return std[:8]
|
||||
|
Reference in New Issue
Block a user