def mobileAppQuite(self): connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: cmd = "adb -s %s shell am force-stop %s" % (device, self.packName) commands.append(cmd) Common().loop_threads(commands)
def deviceConnect(self): commands = [] data = dl().get_Tv_IP() for IP in data: cmd = "adb connect %s" %(IP) commands.append(cmd) Common().loop_threads(commands)
def tvUninstall(self): connectDevices = dl().get_tvDevices() commands = [] for device in connectDevices: cmd = "adb -s %s uninstall %s" % (device, self.packName) commands.append(cmd) Common().loop_threads(commands)
def MobileUninstall(self): connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: cmd = Adb().adbUninstall(device,self.packName) commands.append(cmd) Common().loop_threads(commands)
def MobileInstall(self, apk_path): connectDevices = dl().get_mobileDevices() commands =[] for device in connectDevices: cmd = Adb().adbInstall( device,apk_path) commands.append(cmd) Common().loop_threads(commands)
def mobileBack(self): connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: mobileBack = KeyCode().KeyCode_Back(device) commands.append(mobileBack) Common().loop_threads(commands)
def tvInstall(self, apk_path): connectDevices = dl().get_tvDevices() commands = [] for device in connectDevices: cmd = "adb -s %s install -r %s" % (device, apk_path) commands.append(cmd) Common().loop_threads(commands)
def mobileHome(self): connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: mobileHome = KeyCode().KEYCODE_HOME(device) commands.append(mobileHome) Common().loop_threads(commands)
def MobileAppClear(self): connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: adbClear = Adb().adbClear(device, self.packName) commands.append(adbClear) Common().loop_threads(commands)
def installApk(self, apk_path): connectDevices = dl().get_MobileName() commands = [] for device in connectDevices: cmd = "adb -s %s install -r %s" % (device, apk_path) commands.append(cmd) Common().loop_threads(commands)
def mobileApp(self): connectDevices = dl().get_MobileName() packName = APP().get_apk_package() commands = [] for device in connectDevices: cmd = "adb -s %s shell am force-stop %s" % (device, packName) commands.append(cmd) Common().loop_threads(commands)
def MobileAppRun(self): launchable_activity = APP().get_apk_activity() pack_lauch = self.packName +"/"+ launchable_activity connectDevices = dl().get_mobileDevices() commands = [] for device in connectDevices: cmd = "adb -s %s shell am start -n %s" % (device, pack_lauch) commands.append(cmd) Common().loop_threads(commands)
def Uninstall(self): packName = APP().get_apk_package() connectDevices = dl().get_Tv_IP() commands = [] for device in connectDevices: cmd = "adb -s %s uninstall %s" % (device, packName) commands.append(cmd) Common().loop_threads(commands)
def get_apk_activity(self): cmd = Common().aaPath() + " | findstr launchable-activity:" result = "" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) (output, err) = p.communicate() if output != "": result = output.split()[1].decode()[6:-1] return result
def lauchApp(self): launchable_activity = APP().get_apk_activity() packName = APP().get_apk_package() pack_lauch = packName + "/" + launchable_activity connectDevices = dl().get_Tv_IP() commands = [] for device in connectDevices: cmd = "adb -s %s shell am start -n %s" % (device, pack_lauch) commands.append(cmd) Common().loop_threads(commands)
def get_apk_package(self): cmd = Common().aaPath()+ " | findstr package:" result = "" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) (output, err) = p.communicate() output = str(output, encoding='utf8') if output != "": result = output.split()[1][6:-1] return result
def get_apk_name(self): cmd = Common().aaPath() + " | findstr application-label-zu: " result = "" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) (output, err) = p.communicate() output = str(output, encoding='utf8') if output != "": result = output.split("'")[1] return result
def get_apk_version(self): cmd = Common().aaPath() result = "" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) (output, err) = p.communicate() if output != "": result = output.split()[3].decode()[12:] result = result.split("'")[1] return result
elif i == '7': TvCase().tvAppClear() break elif i == '8': TvCase().tvHome() break elif i == '9': TvCase().tvBack() break else: startInit().Case_Select() elif i == '3': Adb().adbDisconnect() break elif i == '4': Adb().adbRestart() break elif i == '5': Adb().cmdKill() break elif i == 'e': exit(0) else: print("try") continue if __name__ == '__main__': apk_path = Common().apkPath() apk_name = APP().get_apk_package() startInit().Case_Select()
def get_apk_size(self): size = os.path.getsize(Common().apkPath()) / (1024 * 1000) return('%.2f' % size)+ "M" #保留小数点后两位