示例#1
0
def update_assets(host_data, password, delete, names, urls, n_slides):

    host_data = [host for host in host_data if host["enabled"]]

    display_times = []
    for i in range(len(urls)):
        sec_per_slide = round(float(urls[i].split("delayms=")[1]) / 1000.0)
        display_times.append(str(int(sec_per_slide * int(n_slides[i]))))

    # urls need quotes for using as cmd line args
    urls = [f'"{url}"' for url in urls]

    host_data = utils.resolve_ipv4s(host_data)

    # screenly needs at least 2 assets because of memory leak issue
    if len(urls) == 1:
        names.append(names[0] + "_copy")
        urls.append(utils.augment_url(list(urls)[0]))
        display_times.append(display_times[0])

    exit_status = [
        communicate_update(
            [host["ipv4"], password, names, urls, display_times, delete])
        for host in host_data
    ]
    output_status(exit_status)
    app.quit()
示例#2
0
def power_cycle(host_data, command, password):

    host_data = [host for host in host_data if host["enabled"]]
    command = "sudo " + command + " now"
    host_data = utils.resolve_ipv4s(host_data)

    exit_status = [
        utils.toggle_power((host["ipv4"], password, command))
        for host in host_data
    ]
    output_status(exit_status)
    app.quit()
示例#3
0
        slide_times.append(str(int(sec_per_slide * int(n_slides[i]))))

    assets = [f'"{asset}"' for asset in assets]

    if len(assets) == 1:
        names.append(names[0] + "_copy")
        assets.append(augment_asset(list(assets)[0]))
        slide_times.append(slide_times[0])

    n_cpu = max(1, multiprocessing.cpu_count() - 1)

    pool = multiprocessing.Pool(n_cpu)

    print("Finding hosts...")
    host_data = utils.read_local_host_data(c.LOCAL_HOST_DATA_PATH)
    host_data = utils.resolve_ipv4s(host_data)
    ipv4s = list(map(lambda x: x["ipv4"], host_data))
    assert all(ipv4s), "MissingHostError: Not all hosts have been found"
    print("Hosts found...")

    host_range = set(range(utils.enumerate_hosts_from_local_data()))

    while 1:
        screen_numbers = input('Which screens? (numbers or "all" accepted)\n')
        screen_number = screen_numbers.strip()
        valid_input = screen_numbers == "all" or utils.is_all_int(screen_numbers)
        if valid_input:
            if screen_numbers == "all":
                screen_numbers = host_range
                break
            else: