def test_get_crash_log(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") self.no_device = True return udid = mux.devices[0].serial procname = "QQ" lockdown = LockdownClient(udid) self.service = lockdown.startService("com.apple.crashreportcopymobile") client = AFCClient(lockdown, service=self.service) afc_shell = AFCShell(client=client) remote_crash_path = '/' dest_path = '/tmp' local_crashes = [] print('udid:', udid) for _dirname, _dirs, files in afc_shell.afc.dir_walk( remote_crash_path): for filename in files: if procname in filename: remote_crash_file = os.path.join(remote_crash_path, filename) data = afc_shell.afc.get_file_contents(remote_crash_file) local_crash_file = os.path.join(dest_path, filename) local_crashes.append(local_crash_file) with open(local_crash_file, 'wb') as fp: fp.write(data) print(local_crashes)
def test_get_crash_log(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") self.no_device = True return udid = mux.devices[0].serial procname = "QQ" lockdown = LockdownClient(udid) self.service = lockdown.startService("com.apple.crashreportcopymobile") client = AFCClient(lockdown,service=self.service) afc_shell = AFCShell(client=client) remote_crash_path = '/' dest_path = '/tmp' local_crashes =[] print('udid:', udid) for _dirname, _dirs, files in afc_shell.afc.dir_walk(remote_crash_path): for filename in files: if procname in filename: remote_crash_file = os.path.join(remote_crash_path, filename) data = afc_shell.afc.get_file_contents(remote_crash_file) local_crash_file = os.path.join(dest_path, filename) local_crashes.append(local_crash_file) with open(local_crash_file, 'wb') as fp: fp.write(data) print(local_crashes)
def idevice_id(): '''获取当前电脑上连接的所有iOS设备 :return: list - 包含所有iOS设备的UDID的数组 ''' mux = USBMux() if not mux.devices: mux.process(1) return [d.serial for d in mux.devices]
def test_list_devices(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") return syslog = Syslog() syslog.watch(10, '/tmp/sys.log', 'QQ')
def setUp(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") self.no_device = True return self.udid = mux.devices[0].serial self.lockdownclient = LockdownClient(self.udid) self.service = self.lockdownclient.startService("com.apple.mobile.installation_proxy")
def _get_device(self): retry_times = 5 udid = None mux = USBMux() if not mux.devices: mux.process(0.1) while retry_times > 0: if len(mux.devices) > 0: udid = mux.devices[0].serial break mux.process(0.5) retry_times -= 1 return udid
def setUp(self): self.no_device = False mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") self.no_device = True return udid = mux.devices[0].serial self.house_arrest_client = HouseArrestClient(udid) app_bundle_id = "com.gotohack.testapp" result = self.house_arrest_client.send_command(app_bundle_id) if not result: raise RuntimeError("Launching HouseArrest failed for app:%s" % app_bundle_id)
def test_screenshot(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") return udid = mux.devices[0].serial lockdownclient = LockdownClient(udid) tiff_file = tempfile.NamedTemporaryFile(suffix='.tiff') tiff_file_path = tiff_file.name screenshot = screenshotr(lockdownclient) data = screenshot.take_screenshot() with open(tiff_file_path, "wb") as fd: fd.write(data) screenshot.stop_session() tiff_file.close()
def setUp(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") self.no_device = True return udid = mux.devices[0].serial lockdown_client = LockdownClient(udid) self.service = lockdown_client.startService( "com.apple.mobile.house_arrest") self.service.sendPlist({ "Command": "VendContainer", "Identifier": "com.gotohack.testapp" }) status = self.service.recvPlist() if 'Error' in status and status['Error'] == "ApplicationLookupFailed": raise RuntimeWarning('ApplicationLookupFailed') if 'Status' in status and status['Status'] != 'Complete': raise RuntimeWarning('House arrest service launch failed') self.afc = AFCClient(lockdown_client, service=self.service) self.afc_shell = AFCShell(client=self.afc)
def list_devices(): '''获取当前电脑上连接的所有iOS设备 :returns: list - 包含所有iOS设备的UDID的数组 ''' mux = USBMux() if not mux.devices: mux.process(1) for _ in xrange(5): mux.process(0.1) return [d.serial for d in mux.devices]
def test_reboot_device(self): mux = USBMux() if not mux.devices: mux.process(0.1) if len(mux.devices) == 0: print("no real device found") return udid = mux.devices[0].serial lockdown = LockdownClient(udid) DIAGClient(lockdown).restart() time.sleep(10) for _ in range(20): mux.process(1) for dev in mux.devices: if udid == dev.serial: print('reboot successfully') return else: self.fail('reboot error: real device disconect')
def test_list_devices(self): mux = USBMux() if not mux.devices: mux.process(0.1) self.assertTrue(len(mux.devices)>=0, 'usbmuxd通信异常')
def test_list_devices(self): mux = USBMux() if not mux.devices: mux.process(0.1) self.assertTrue(len(mux.devices) >= 0, 'usbmuxd communication error')
def test_list_devices(self): mux = USBMux() if not mux.devices: mux.process(0.1) self.assertTrue(len(mux.devices)>=0, 'usbmuxd communication error')
def test_list_devices(self): mux = USBMux() if not mux.devices: mux.process(0.1) self.assertTrue(len(mux.devices) >= 0, 'usbmuxd通信异常')