diff options
author | Andrew Lassalle <andrewlassalle@chromium.org> | 2019-11-05 13:30:34 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-19 20:22:42 +0000 |
commit | 165843ca10908d7bd79582829a5ee51b098685e6 (patch) | |
tree | c4c98899ca4d134af1b2655afbe17dc7cb843b40 /scripts/update_device.py | |
parent | d04ca0c5cc9e4507301be355fd3bd86b871b05c4 (diff) |
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>
Diffstat (limited to 'scripts/update_device.py')
-rwxr-xr-x | scripts/update_device.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/update_device.py b/scripts/update_device.py index 5c19b89a..f970bd3e 100755 --- a/scripts/update_device.py +++ b/scripts/update_device.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python # # Copyright (C) 2017 The Android Open Source Project # @@ -17,8 +17,9 @@ """Send an A/B update to an Android device over adb.""" +from __future__ import absolute_import + import argparse -import BaseHTTPServer import hashlib import logging import os @@ -29,6 +30,8 @@ import threading import xml.etree.ElementTree import zipfile +from six.moves import BaseHTTPServer + import update_payload.payload @@ -41,6 +44,7 @@ PAYLOAD_KEY_PATH = '/etc/update_engine/update-payload-key.pub.pem' # The port on the device that update_engine should connect to. DEVICE_PORT = 1234 + def CopyFileObjLength(fsrc, fdst, buffer_size=128 * 1024, copy_length=None): """Copy from a file object to another. @@ -130,7 +134,6 @@ class UpdateHandler(BaseHTTPServer.BaseHTTPRequestHandler): start_range = file_size - int(e) return start_range, end_range - def do_GET(self): # pylint: disable=invalid-name """Reply with the requested payload file.""" if self.path != '/payload': @@ -173,7 +176,6 @@ class UpdateHandler(BaseHTTPServer.BaseHTTPRequestHandler): f.seek(serving_start + start_range) CopyFileObjLength(f, self.wfile, copy_length=end_range - start_range) - def do_POST(self): # pylint: disable=invalid-name """Reply with the omaha response xml.""" if self.path != '/update': @@ -442,5 +444,6 @@ def main(): return 0 + if __name__ == '__main__': sys.exit(main()) |