1 # -*- coding: utf-8 -*- 2 3 import sys 4 import os 5 import time 6 import string 7 8 import common 9 10 def install (extraArgs = []): 11 curDir = os.getcwd() 12 try: 13 os.chdir(common.ANDROID_DIR) 14 15 print "Removing old dEQP Package..." 16 common.execArgs([common.ADB_BIN] + extraArgs + [ 17 'uninstall', 18 'com.drawelements.deqp' 19 ]) 20 print "" 21 22 print "Installing dEQP Package..." 23 common.execArgs([common.ADB_BIN] + extraArgs + [ 24 'install', 25 '-r', 26 'package/bin/dEQP-debug.apk' 27 ]) 28 print "" 29 30 finally: 31 # Restore working dir 32 os.chdir(curDir) 33 34 def installToDevice (device): 35 print "Installing to %s (%s)..." % (device.serial, device.model) 36 install(['-s', device.serial]) 37 38 def installToAllDevices (): 39 devices = common.getDevices(common.ADB_BIN) 40 for device in devices: 41 installToDevice(device) 42 43 if __name__ == "__main__": 44 if len(sys.argv) > 1: 45 if sys.argv[1] == '-a': 46 installToAllDevices() 47 else: 48 install(sys.argv[1:]) 49 else: 50 devices = common.getDevices(common.ADB_BIN) 51 if len(devices) == 0: 52 common.die('No devices connected') 53 elif len(devices) == 1: 54 installToDevice(devices[0]) 55 else: 56 print "More than one device connected:" 57 for i in range(0, len(devices)): 58 print "%3d: %16s %s" % ((i+1), devices[i].serial, devices[i].model) 59 60 deviceNdx = int(raw_input("Choose device (1-%d): " % len(devices))) 61 installToDevice(devices[deviceNdx-1]) 62