From 195c2066696285714802a22ec6d39e0d7fd13ade Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Sat, 25 May 2019 13:59:07 +0100 Subject: [PATCH] distro-tool: handle garbage in error response --- tools/distro-tool | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/distro-tool b/tools/distro-tool index 075a855a60..71b3b1473c 100755 --- a/tools/distro-tool +++ b/tools/distro-tool @@ -104,7 +104,13 @@ class MyUtility(object): return (0, subprocess.check_output(command.split(" "), stderr=_logfile)) except subprocess.CalledProcessError as cpe: if MyUtility.isPython3: - return (cpe.returncode, cpe.output.decode("utf-8")) + # Clean up undecodable garbage in response (eg. libftdi1 error page) + output = bytearray() + for c in cpe.output: + if c <= 127: + output.append(c) + + return (cpe.returncode, output.decode("utf-8")) else: return (cpe.returncode, cpe.output) finally: