def _start_app(self): bundle_id = self.tc_bundle_id.GetValue() while(True): if self._process_dlg_running: break dlg = self._dialog try: xcode_version = self._device_driver.get_xcode_version() ios_version = self._device_driver.get_ios_version() Log.i('xcode_version:%s ios_version:%s' % (xcode_version, ios_version)) # 增加版本检测 self._run_in_main_thread(dlg.on_update) self._app_started = self._device_driver.start_app(bundle_id) if self._app_started: self._run_in_main_thread(self.statusbar.SetStatusText, u"App启动成功", 0) self._run_in_main_thread(dlg.on_update_title_msg, '抓取App屏幕中......') img_data = self._device_driver.take_screenshot() self._orientation = self._device_driver.get_screen_orientation() self._run_in_main_thread(self._update_screenshot, img_data) self._run_in_main_thread(dlg.on_update_title_msg, '抓取App控件树中......') self._element_tree = self._device_driver.get_element_tree() self._run_in_main_thread(self._update_uitree) else: self._run_in_main_thread(self.statusbar.SetStatusText, u"App启动失败:", 0) except: error = traceback.format_exc() Log.e('start_app', error) self._run_in_main_thread(self.create_tip_dialog, error.decode('utf-8')) self._process_dlg_running = False self._run_in_main_thread(dlg.on_destory)
def _update_bundle_id_list(self): ''' 在连接设备或者更换设备时,更新bundle_id列表 ''' print self._device self._device_driver = DeviceDriver(self._host_driver.host_url, self._device['udid']) original_bundle_id = self.tc_bundle_id.GetValue() self.tc_bundle_id.Clear() if self._device['simulator']: self._host_driver.start_simulator(self._device['udid']) self._app_list = self._device_driver.get_app_list(self._app_type) Log.i('app_list:', str(self._app_list)) bundle_list = [] remove_dev = None if self._app_list: for dev in self._app_list: bundle = dev.keys()[0] if bundle == 'com.apple.test.XCTestAgent-Runner': remove_dev = dev continue bundle_list.append(bundle) self.tc_bundle_id.Append(bundle.decode('utf-8'), dev) index = bundle_list.index(original_bundle_id) if original_bundle_id and original_bundle_id in bundle_list else 0 self._run_in_main_thread(self.tc_bundle_id.Select, index) if remove_dev: self._app_list.remove(dev) if self.treeframe: self._run_in_main_thread(self.on_update_sandbox_view) else: self.create_tip_dialog(u'设备未启动或无可用APP') return
# governing permissions and limitations under the License. # '''UISpy App启动入口 ''' import wx from mainframe import MainFrame from util.logger import Log class UISpyApp(wx.App): def OnInit(self): self.main = MainFrame() self.main.Center() self.main.Show() self.SetTopWindow(self.main) return True if __name__ == '__main__': try: Log.i('main', 'UISpy started...') app = UISpyApp() app.MainLoop() except: import traceback message = traceback.format_exc() Log.e('main', message) dialog = wx.MessageDialog(None, message, u"错误", wx.OK | wx.ICON_ERROR) dialog.ShowModal()