diff options
author | Yilin Yang <kerker@google.com> | 2020-09-22 15:52:12 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-24 07:19:00 +0000 |
commit | 64f58afcf6512f313c69e37e8a6b2047aba2014e (patch) | |
tree | cfc5a91c25b128f89073a3368d5704f75230eddf | |
parent | 7928c23272ecc4bf551b1e4dcb96a0d9b4a46ec7 (diff) | |
download | chrome-ec-64f58afcf6512f313c69e37e8a6b2047aba2014e.tar.gz |
util: Migrate unpack_ftb.py to python2/3 compatible
BUG=chromium:1031705
BRANCH=master
TEST=1. Download ftb files from nocturne board.
(chromeos-touch-firmware-whiskers/release_37_0.7z)
2. Make sure the output is the same after migration.
Signed-off-by: kerker <kerker@chromium.org>
Change-Id: I5fc43b36764ba53a70d298659ff48172da8a5e0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2423451
Reviewed-by: Stimim Chen <stimim@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
-rwxr-xr-x | util/unpack_ftb.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/util/unpack_ftb.py b/util/unpack_ftb.py index 105f7044ec..4829a89d82 100755 --- a/util/unpack_ftb.py +++ b/util/unpack_ftb.py @@ -1,8 +1,10 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # Copyright 2018 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 import ctypes @@ -58,7 +60,7 @@ def main(): parser.add_argument('--output', '-o', required=True) args = parser.parse_args() - with open(args.input) as f: + with open(args.input, 'rb') as f: bs = f.read() size = len(bs) @@ -91,7 +93,7 @@ def main(): with open(args.output, 'wb') as f: # ensure the file size f.seek(OUTPUT_FILE_SIZE - 1, os.SEEK_SET) - f.write('\x00') + f.write(b'\x00') f.seek(0, os.SEEK_SET) f.write(bs[0 : ctypes.sizeof(header)]) |