update_payload: Port scripts to python3
Update the update_payload scripts to be compatible with
python2 and python3. Python2 compatibility is needed since
the repo is shared with Android.
BUG=chromium:1011631
TEST=Executed aosp/system/update_engine/scripts/run_unittests and
cros_generate_update_payload
Cq-Depend: chromium:1904837, chromium:1911499
Change-Id: Ie450b80b5f7550051b38d320173ccc0c915f65e7
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1904310
Commit-Queue: Andrew Lassalle <andrewlassalle@chromium.org>
Tested-by: Andrew Lassalle <andrewlassalle@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Auto-Submit: Andrew Lassalle <andrewlassalle@chromium.org>
diff --git a/scripts/update_payload/payload.py b/scripts/update_payload/payload.py
index 1ed5f99..ea5ed30 100644
--- a/scripts/update_payload/payload.py
+++ b/scripts/update_payload/payload.py
@@ -16,6 +16,7 @@
"""Tools for reading, verifying and applying Chrome OS update payloads."""
+from __future__ import absolute_import
from __future__ import print_function
import hashlib
@@ -64,7 +65,7 @@
"""Update payload header struct."""
# Header constants; sizes are in bytes.
- _MAGIC = 'CrAU'
+ _MAGIC = b'CrAU'
_VERSION_SIZE = 8
_MANIFEST_LEN_SIZE = 8
_METADATA_SIGNATURE_LEN_SIZE = 4
@@ -111,7 +112,6 @@
payload_file, self._METADATA_SIGNATURE_LEN_SIZE, True,
hasher=hasher)
-
def __init__(self, payload_file, payload_file_offset=0):
"""Initialize the payload object.