Esempio n. 1
0
def connect_adb_wifi(addr):
    """
    Run adb connect, and then call connect_usb(..)

    Args:
        addr: ip+port which can be used for "adb connect" argument
    
    Raises:
        ConnectError
    """
    assert isinstance(addr, six.string_types)

    subprocess.call([adbutils.adb_path(), "connect", addr])
    try:
        subprocess.call([adbutils.adb_path(), "-s", addr, "wait-for-device"], timeout=2)
    except subprocess.TimeoutExpired:
        raise ConnectError("Fail execute", "adb connect " + addr)
    return connect_usb(addr)
Esempio n. 2
0
def connect_wifi(addr: str) -> "UIAutomatorServer":
    """
    Args:
        addr (str) uiautomator server address.

    Returns:
        UIAutomatorServer

    Raises:
        ConnectError

    Examples:
        connect_wifi("10.0.0.1")
    """
    fixed_addr = fix_wifi_addr(addr)
    if fixed_addr is None:
        raise ConnectError("addr is invalid or atx-agent is not running", addr)
    u = urlparse.urlparse(fixed_addr)
    host = u.hostname
    port = u.port or 7912
    return UIAutomatorServer(host, port)
Esempio n. 3
0
def connect_wifi(addr=None):
    """
    Args:
        addr (str) uiautomator server address.

    Returns:
        UIAutomatorServer

    Raises:
        ConnectError

    Examples:
        connect_wifi("10.0.0.1")
    """
    if '://' not in addr:
        addr = 'http://' + addr
    if addr.startswith('http://'):
        u = urlparse.urlparse(addr)
        host = u.hostname
        port = u.port or 7912
        return UIAutomatorServer(host, port)
    else:
        raise ConnectError("address should start with http://")