def test_info(self): usb = self.usb local = self.local self.assertIsInstance(core.device_type(local), str) # need an iOS device self.assertEqual(core.device_type(usb), 'iOS') self.assertIsInstance(core.devices(), list) self.assertIsInstance(core.ps(local), list) self.assertIsInstance(core.apps(usb), list)
def main(args): from backend import core, rpc, syslog from backend.file import upload, download from backend.fs import FileSystem if args.action == 'devices': return core.devices() if not args.device: raise RuntimeError('NOTREACHED') device = core.get_device(args.device) if args.action == 'ps': return core.ps(device) if args.action == 'apps': return core.apps(device) if args.action == 'type': return core.device_type(device) target = args.pid or args.name agent = rpc.ProcessAgent(device, target) if target else \ rpc.AppAgent(device, args.app) agent.load() if args.action == 'rpc': return agent.invoke(args.method, *args.args) if args.action == 'syslog': syslog.pipe(agent) return fs = FileSystem(agent) if args.action == 'fs': method = getattr(fs, args.method) return method(*args.args) if args.action == 'download': download(fs, args.path) return if args.action == 'upload': upload(fs, args.path) return raise RuntimeError('NOTREACHED')
def main(args): from backend import core, rpc, syslog from backend.file import upload, download from backend.fs import FileSystem from backend.ios.copyid import install from backend.ios.debugserver import setup from backend.ios.installer import apps if args.action == 'devices': return core.devices() if not args.device: raise RuntimeError('NOTREACHED') device = core.get_device(args.device) if args.action == 'ps': return core.ps(device) if args.action == 'apps': return core.apps(device) if args.action == 'type': return core.device_type(device) if args.action == 'ssh-copy-id': return install(device) if args.action == 'sign-debugserver': return setup(device) if args.action == 'port': return core.find_port(device) if args.action == 'location': return next(app['Path'] for app in apps(device) if app['CFBundleIdentifier'] == args.bundle) target = args.pid or args.name agent = rpc.ProcessAgent(device, target) if target else \ rpc.AppAgent(device, args.app) agent.load() if args.action == 'rpc': return agent.invoke(args.method, *args.args) if args.action == 'syslog': syslog.pipe(agent) return fs = FileSystem(agent) if args.action == 'fs': method = getattr(fs, args.method) return method(*args.args) if args.action == 'download': download(fs, args.path) return if args.action == 'upload': upload(fs, args.path) return raise RuntimeError('NOTREACHED')