Example #1
0
async def async_main():
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    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("--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()

    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)

    # 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)
Example #2
0
 def __init__(self, serial: str, callback=nop_callback):
     self._serial = serial
     self._procs = []
     self._current_ip = current_ip()
     self._device = adbclient.device(serial)
     self._callback = callback