async def async_main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) # yapf: disable parser.add_argument('-s', '--server', default='localhost:4000', help='server address') parser.add_argument("--allow-remote", action="store_true", help="allow remote connect device") parser.add_argument('-t', '--test', action="store_true", help="run test code") parser.add_argument('-p', '--port', type=int, default=3500, help='listen port') parser.add_argument("--atx-agent-version", default=u2.version.__atx_agent_version__, help="set atx-agent version") parser.add_argument("--owner", type=str, help="provider owner email") parser.add_argument("--owner-file", type=argparse.FileType("r"), help="provider owner email from file") args = parser.parse_args() # yapf: enable settings.atx_agent_version = args.atx_agent_version owner_email = args.owner if args.owner_file: with args.owner_file as file: owner_email = file.read().strip() logger.info("Owner: %s", owner_email) if args.test: for apk_name in ("cloudmusic.apk", ): # , "apkinfo.exe"): apk_path = "testdata/" + apk_name logger.info("Install %s", apk_path) # apk_path = r"testdata/cloudmusic.apk" ret = app_install_local("6EB0217704000486", apk_path, launch=True) logger.info("Ret: %s", ret) return # start local server provider_url = "http://" + current_ip() + ":" + str(args.port) app = make_app() app.listen(args.port) logger.info("ProviderURL: %s", provider_url) fetching.get_all() # connect to atxserver2 global hbconn hbconn = await heartbeat_connect(args.server, secret=secret, self_url=provider_url, owner=owner_email) await device_watch(args.allow_remote)
self_url=provider_url, owner=owner_email) await device_watch(args.allow_remote) async def test_asyncadb(): devices = await adb.devices() print(devices) # output = await adb.shell("3578298f", "getprop ro.product.brand") # print(output) version = await adb.server_version() print("ServerVersion:", version) await adb.forward_remove() await adb.forward("3578298f", "tcp:8888", "tcp:7912") async for f in adb.forward_list(): print(f) if __name__ == '__main__': # if os.path.getsize(os.path.join(__curdir__, # "vendor/app-uiautomator.apk")) < 1000: # sys.exit("Did you forget run\n\tgit lfs install\n\tgit lfs pull") try: fetching.get_all() IOLoop.current().run_sync(async_main) except KeyboardInterrupt: logger.info("Interrupt catched")