aboutsummaryrefslogtreecommitdiff
path: root/chromiumos_image_diff.py
diff options
context:
space:
mode:
authorZhizhou Yang <zhizhouy@google.com>2020-02-10 16:51:20 -0800
committerZhizhou Yang <zhizhouy@google.com>2020-02-12 01:34:49 +0000
commit81d651f89ac91819a77b8bd2ca720646326bf89a (patch)
treeec2f44c02809b95d036a8c619834ec4db8dba2e4 /chromiumos_image_diff.py
parent4b68aee96e6c6b7593b8d91973168c817852b2b2 (diff)
downloadtoolchain-utils-81d651f89ac91819a77b8bd2ca720646326bf89a.tar.gz
toolchain-utils: Partially port scripts to python 3
This patch ports some still-in-use python scripts under root directory of toolchain-utils to python 3. BUG=chromium:1011676 TEST=Passed unittests and tested with manually launching. Change-Id: Id6066944780a7204fe4746cd271f41ac20f2274d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2049103 Commit-Queue: Zhizhou Yang <zhizhouy@google.com> Tested-by: Zhizhou Yang <zhizhouy@google.com> Auto-Submit: Zhizhou Yang <zhizhouy@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'chromiumos_image_diff.py')
-rwxr-xr-xchromiumos_image_diff.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/chromiumos_image_diff.py b/chromiumos_image_diff.py
index 74906d32..66a54ccc 100755
--- a/chromiumos_image_diff.py
+++ b/chromiumos_image_diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2019 The Chromium OS Authors. All rights reserved.
@@ -86,7 +86,7 @@ class CrosImage(object):
'{r}/var {r}/mnt/stateful_partition {r}; sudo umount {s} ; '
'rmdir {r} ; rmdir {s}\n').format(
r=self.rootfs, s=self.stateful)
- f = open(self.unmount_script, 'w')
+ f = open(self.unmount_script, 'w', encoding='utf-8')
f.write(command)
f.close()
self._ce.RunCommand(
@@ -160,9 +160,9 @@ class ImageComparator(object):
i1 = self.images[0]
i2 = self.images[1]
t1 = i1.rootfs + '/'
- elfset1 = set([e.replace(t1, '') for e in i1.elf_files])
+ elfset1 = {e.replace(t1, '') for e in i1.elf_files}
t2 = i2.rootfs + '/'
- elfset2 = set([e.replace(t2, '') for e in i2.elf_files])
+ elfset2 = {e.replace(t2, '') for e in i2.elf_files}
dif1 = elfset1.difference(elfset2)
msg = None
if dif1:
@@ -210,15 +210,15 @@ class ImageComparator(object):
if full_path1 == full_path2:
self.logger.LogError(
- 'Error: We\'re comparing the SAME file - {0}'.format(f1))
+ "Error: We're comparing the SAME file - {0}".format(f1))
continue
command = (
'objdump -d "{f1}" > {tempf1} ; '
'objdump -d "{f2}" > {tempf2} ; '
# Remove path string inside the dissemble
- 'sed -i \'s!{rootfs1}!!g\' {tempf1} ; '
- 'sed -i \'s!{rootfs2}!!g\' {tempf2} ; '
+ "sed -i 's!{rootfs1}!!g' {tempf1} ; "
+ "sed -i 's!{rootfs2}!!g' {tempf2} ; "
'diff {tempf1} {tempf2} 1>/dev/null 2>&1').format(
f1=full_path1,
f2=full_path2,