Esempio n. 1
0
def write_blacklist(device):
    print(black_list)
    if not os.path.exists(black_list):
        get_blacklist()
    cmd = "adb push {} /sdcard/{}".format(black_list,
                                          os.path.basename(black_list))
    run_command_on_shell(cmd)
Esempio n. 2
0
def write_blacklist(device):
    print(black_list)
    if not os.path.exists(black_list):
        get_blacklist()
    cmd = "adb push {} /sdcard/{}".format(black_list,
                                          os.path.basename(black_list))
    run_command_on_shell(cmd)

    cmd = "adb devices"
    result = run_command_on_shell(cmd)
    print(result)

    dev = ""

    for i in result[1:]:
        if i != "":
            each_device = {}
            nPos = i.index("\t")
            dev = i[:nPos]
            print(dev)
        else:
            "no devices"

    devices = dev

    # get_blacklist()
    #
    write_blacklist(devices)
Esempio n. 3
0
def kill_adb_port():
    cmd = "lsof -i tcp:5037"
    result = run_command_on_shell(cmd)
    # record = result.split("\n")[1]
    # port = record.split(" ")[1]
    port = re.search("\d+", result[1])
    if port:
        cmd_port = "kill -9 {}".format(port.group(0))
        run_command_on_shell(cmd_port)
Esempio n. 4
0
def start_appium_server(device):
    #close_appium_server()

    host = "0.0.0.0"

    port = device['port']
    bootstrap_port = device['bootstrap']
    udid = device['id']
    appium_log = log_dir + "/" + "server.log"

    # print("start appium server")
    # cmd = CMD.format(host,port,bootstrap_port)
    # print(cmd)
    # os.popen(cmd)
    # time.sleep(WAIT_TIME)
    cmd = CMD.format(host, port, bootstrap_port, udid, appium_log)
    run_command_on_shell(cmd)
    time.sleep(WAIT_TIME)
Esempio n. 5
0
def run_monkey(device):

    cmd = "adb -s {} shell monkey -p {} --ignore-timeouts --ignore-native-crashes -v -v -v --throttle 200 500 > {}".format(
        device['id'],
        YAML().get_package(),
        get_log(device)[0])
    run_command_on_shell(cmd)
    cmd2 = "adb logcat -v >{}".format(get_log(device)[1])
    run_command_on_shell(cmd2)
    cmd3 = "adb shell pm clear {}".format(YAML().get_package())
    run_command_on_shell(cmd3)
Esempio n. 6
0
def get_blacklist():
    cmd = "adb shell pm list packages -s > {}".format(black_list)
    run_command_on_shell(cmd)
Esempio n. 7
0
def list_devices():
    cmd = "adb devices"
    result = run_command_on_shell(cmd)
    print(result)
    return result
Esempio n. 8
0
def get_devices_name(device):
    cmd = "adb -s {} shell getprop ro.product.model".format(device)
    result = run_command_on_shell(cmd)[0]
    return result
Esempio n. 9
0
def get_devices_version(device):
    cmd = "adb -s {} shell getprop ro.build.version.release".format(device)
    result = run_command_on_shell(cmd)[0]
    return result
Esempio n. 10
0
    run_command_on_shell(cmd)


def write_blacklist(device):
    print(black_list)
    if not os.path.exists(black_list):
        get_blacklist()
    cmd = "adb push {} /sdcard/{}".format(black_list,
                                          os.path.basename(black_list))
    run_command_on_shell(cmd)


if __name__ == '__main__':

    cmd = "adb devices"
    result = run_command_on_shell(cmd)
    print(result)

    dev = ""

    for i in result[1:]:
        if i != "":
            each_device = {}
            nPos = i.index("\t")
            dev = i[:nPos]
            print(dev)
        else:
            "no devices"

    devices = dev