mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00: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:
parent
533a2fd2c1
commit
8aa9d672a1
@ -97,7 +97,7 @@ class AcmeCapeInstrument(Instrument):
|
||||
raise HostError(msg.format(output))
|
||||
if self.process.returncode != 15: # iio-capture exits with 15 when killed
|
||||
if sys.version_info[0] == 3:
|
||||
output += self.process.stdout.read().decode(sys.stdout.encoding)
|
||||
output += self.process.stdout.read().decode(sys.stdout.encoding, 'replace')
|
||||
else:
|
||||
output += self.process.stdout.read()
|
||||
self.logger.info('ACME instrument encountered an error, '
|
||||
|
@ -82,8 +82,8 @@ class EnergyProbeInstrument(Instrument):
|
||||
if self.process.returncode is not None:
|
||||
stdout, stderr = self.process.communicate()
|
||||
if sys.version_info[0] == 3:
|
||||
stdout = stdout.decode(sys.stdout.encoding)
|
||||
stderr = stderr.decode(sys.stdout.encoding)
|
||||
stdout = stdout.decode(sys.stdout.encoding, 'replace')
|
||||
stderr = stderr.decode(sys.stdout.encoding, 'replace')
|
||||
raise HostError(
|
||||
'Energy Probe: Caiman exited unexpectedly with exit code {}.\n'
|
||||
'stdout:\n{}\nstderr:\n{}'.format(self.process.returncode,
|
||||
|
@ -278,7 +278,7 @@ class FtraceCollector(TraceCollector):
|
||||
process = subprocess.Popen(command, stderr=subprocess.PIPE, shell=True)
|
||||
_, error = process.communicate()
|
||||
if sys.version_info[0] == 3:
|
||||
error = error.decode(sys.stdout.encoding)
|
||||
error = error.decode(sys.stdout.encoding, 'replace')
|
||||
if process.returncode:
|
||||
raise TargetError('trace-cmd returned non-zero exit code {}'.format(process.returncode))
|
||||
if error:
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user