summaryrefslogtreecommitdiff
path: root/scripts/update_device.py
diff options
context:
space:
mode:
authorAndroid Build Role Account android-build-prod <android-build-team-robot@google.com>2020-09-21 23:16:07 +0000
committerAndroid Build Role Account android-build-prod <android-build-team-robot@google.com>2020-09-21 23:16:07 +0000
commitc0d59af7348f9745e12a8581a05bd3a8fdb472fe (patch)
tree798c7a596105ea07027dcb8c2aa748d70ffe673b /scripts/update_device.py
parent1df8e19776bae4f4bd40d3612ca24d296a61801e (diff)
parent5ef6aa3fa1b0b7d539ed40ba34d9c7a9da330d10 (diff)
Snap for 6852288 from 5ef6aa3fa1b0b7d539ed40ba34d9c7a9da330d10 to s-keystone-qcom-release
Change-Id: I619850ed167e740c8816851854d07ca7a6019273
Diffstat (limited to 'scripts/update_device.py')
-rwxr-xr-xscripts/update_device.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/update_device.py b/scripts/update_device.py
index 49f766da..7be3edbf 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.
@@ -137,7 +141,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':
@@ -180,7 +183,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':
@@ -451,5 +453,6 @@ def main():
return 0
+
if __name__ == '__main__':
sys.exit(main())