[autotest]: Ensure docker container exec output is compatible with python env
Change-Id: Iceb8c00f393d4969a82af9392d1e5c438df9d00f
BUG:b:217780680
TEST:Manually tested this on the satlab.
Change-Id: I93dceb233091137c71b47c2d5939c02de6f9e551
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3440921
Reviewed-by: Anh Le <anhdle@chromium.org>
Tested-by: Prasad Vuppalapu <prasadv@chromium.org>
Commit-Queue: Prasad Vuppalapu <prasadv@chromium.org>
diff --git a/server/hosts/base_servohost.py b/server/hosts/base_servohost.py
index 1a3de7f..89878c6 100644
--- a/server/hosts/base_servohost.py
+++ b/server/hosts/base_servohost.py
@@ -610,6 +610,9 @@
try:
(exit_code,
output) = container.exec_run("bash -c '%s'" % command)
+ # b/217780680, Make this compatible with python3,
+ if isinstance(output, bytes):
+ output = output.decode(errors='replace')
except docker.errors.APIError:
logging.exception("Failed to run command %s", command)
for line in container.logs().split(b'\n'):
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index f247476..869fb40 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -745,6 +745,9 @@
exit_code, output = container.exec_run(
cmd="servodtool instance wait-for-active -p 9999",
stdout=True)
+ # b/217780680, Make this compatible with python3,
+ if isinstance(output, bytes):
+ output = output.decode(errors='replace')
if exit_code != 0 or ready_output not in output:
logging.debug(
'Failed to start servod process inside container,'