summaryrefslogtreecommitdiff
path: root/extra/usb_updater
diff options
context:
space:
mode:
authorYilin Yang <kerker@google.com>2020-09-23 14:57:09 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-26 02:04:19 +0000
commitdac57f3eb1cad9e181ea7efa130299a473db50a6 (patch)
tree06889a1ebc1bca14bb9d970b490e6accb49284ac /extra/usb_updater
parentd888a8e84e8739cc4d3e89f7c534b49e360e34ad (diff)
downloadchrome-ec-dac57f3eb1cad9e181ea7efa130299a473db50a6.tar.gz
usb_updater: Migrate servo_updater.py to python2/3 compatible
BUG=chromium:1031705 BRANCH=master TEST=`sudo python3 ./extra/usb_updater/servo_updater.py -b servo_v4 --force` shows "update complete". TEST=`sudo python2 ./extra/usb_updater/servo_updater.py -b servo_v4 --force` shows "update complete". Signed-off-by: kerker <kerker@chromium.org> Change-Id: I632203b9eca4aa99dc63063c37f0ab5fc2e54dbb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2425784 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'extra/usb_updater')
-rwxr-xr-xextra/usb_updater/servo_updater.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py
index 06c36f37b6..397aa28566 100755
--- a/extra/usb_updater/servo_updater.py
+++ b/extra/usb_updater/servo_updater.py
@@ -1,8 +1,10 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# Note: This is a py2/3 compatible file.
+
from __future__ import print_function
import argparse
@@ -14,6 +16,8 @@ import time
import tempfile
import json
+import six
+
import fw_update
import ecusb.tiny_servo_common as c
@@ -236,8 +240,13 @@ def find_available_version(boardname, binfile):
Returns:
the version string.
"""
+ args = {}
+ if six.PY3:
+ args['encoding'] = 'utf-8'
+
rawstrings = subprocess.check_output(
- ['cbfstool', binfile, 'read', '-r', 'RO_FRID', '-f', '/dev/stdout'])
+ ['cbfstool', binfile, 'read', '-r', 'RO_FRID', '-f', '/dev/stdout'],
+ **args)
m = re.match(r'%s_v\S+' % boardname, rawstrings)
if m:
newvers = m.group(0).strip(' \t\r\n\0')