factory: Set encoding for `subprocess.check_output`
`subprocess.check_output` returns bytes by default, we will get errors if
we treat it as str type when processing. In python3, we should use str
type as much as possible, so we can set encoding or use
`process_utils.CheckOutput` to get the output in str type.
pygpt will be used in par, so I don't use process_utils here.
BUG=chromium:999876
TEST=make test
TEST=`pygpt find -l 123` will not show "/dev/b'sda' not found" errors
TEST=(1) Check output of `i2cdetect -r 0` in dut
(2) Run cmds in python interpreter and check
Change-Id: Ia06f98ecaed05af47235b1c57bb5ba47aa1ebfbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/2182094
Reviewed-by: Pin-yen Lin <treapking@chromium.org>
Commit-Queue: Yilin Yang (kerker) <kerker@chromium.org>
Tested-by: Yilin Yang (kerker) <kerker@chromium.org>
diff --git a/py/utils/pygpt.py b/py/utils/pygpt.py
index fd4b66a..ed3e9cf 100755
--- a/py/utils/pygpt.py
+++ b/py/utils/pygpt.py
@@ -1563,7 +1563,7 @@
drives = [args.drive.name] if args.drive else (
'/dev/%s' % name for name in subprocess.check_output(
- 'lsblk -d -n -r -o name', shell=True).split())
+ 'lsblk -d -n -r -o name', shell=True, encoding='utf-8').split())
match_pattern = None
if args.match_file: