コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
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]
コード例 #4
0
 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')
コード例 #5
0
 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")
コード例 #6
0
 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
コード例 #7
0
 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)
コード例 #8
0
 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()
コード例 #9
0
 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)
コード例 #10
0
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]
コード例 #11
0
 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
コード例 #12
0
 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')
コード例 #13
0
 def test_list_devices(self):
     mux = USBMux()
     if not mux.devices:
         mux.process(0.1)
     self.assertTrue(len(mux.devices)>=0, 'usbmuxd通信异常')
コード例 #14
0
 def test_list_devices(self):
     mux = USBMux()
     if not mux.devices:
         mux.process(0.1)
     self.assertTrue(len(mux.devices) >= 0, 'usbmuxd communication error')
コード例 #15
0
 def test_list_devices(self):
     mux = USBMux()
     if not mux.devices:
         mux.process(0.1)
     self.assertTrue(len(mux.devices)>=0, 'usbmuxd communication error')
コード例 #16
0
 def test_list_devices(self):
     mux = USBMux()
     if not mux.devices:
         mux.process(0.1)
     self.assertTrue(len(mux.devices) >= 0, 'usbmuxd通信异常')