Fix install_apk.py Python 3 migration
authorTim Van Patten <timvp@google.com>
Wed, 19 Jun 2019 15:49:56 +0000 (09:49 -0600)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 28 Jun 2019 10:19:05 +0000 (06:19 -0400)
The current install_apk.py hits errors with Python3 which this attempts
to address.

VK-GL-CTS issue: 1665

Change-Id: I38cb2ffc991f19a8cb95cef4d102a968c4a78bf2

scripts/android/install_apk.py

index 6f5b14b..51fe65c 100644 (file)
@@ -61,7 +61,7 @@ def getDevices (adbPath):
                if len(line.strip()) == 0:
                        continue
 
-               m = ptrn.match(line)
+               m = ptrn.match(line.decode('utf-8'))
                if m == None:
                        print("WARNING: Failed to parse device info '%s'" % line)
                        continue
@@ -77,7 +77,7 @@ def execWithPrintPrefix (args, linePrefix="", failOnNonZeroExit=True):
                        line = source.readline()
                        if len(line) == 0: # EOF
                                break;
-                       sink.write(prefix + line)
+                       sink.write(prefix + line.decode('utf-8'))
 
        process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdoutJob = threading.Thread(target=readApplyPrefixAndPrint, args=(process.stdout, linePrefix, sys.stdout))
@@ -233,7 +233,7 @@ if __name__ == "__main__":
                                for i in range(0, len(devices)):
                                        print("%3d: %16s %s" % ((i+1), devices[i].serial, devices[i].model))
 
-                               deviceNdx = int(raw_input("Choose device (1-%d): " % len(devices)))
+                               deviceNdx = int(input("Choose device (1-%d): " % len(devices)))
                                installToDevice(devices[deviceNdx-1], args.adbPath, packageName, apkPath)
                else:
                        devices = getDevices(args.adbPath)