Exemple #1
0
def top():
    standard_screen = StdScreen()
    standard_screen.disable_cursor_and_key_echo()

    lc = LayoutCreator(standard_screen.MAX_WIDTH, standard_screen.MAX_HEIGHT)
    layouts = lc.create_layouts()

    containers = create_app_containers(layouts, lc.cgroup_names)

    # Thread to periodically fetch data
    # and update the view.
    data_updater = BackgroundThread(
        DataCollector().update_widget_data,
        REFRESH_INTERVAL, containers
    )
    data_updater.start()

    # Prevents used from bombarding with
    # key events.
    delay_output(1000)

    current_hightlight = containers[0]
    # Wait forever until we receive
    containers[0].process_list_bar.set_highlight(True)
    # an exit key.
    try:
        while True:
            key = standard_screen.stdscr.getch()
            if key in EXIT_KEYS:
                break

            current_hightlight = dispatch_to_container(containers, current_hightlight, key)

        data_updater.stop()

        endwin()
    except Exception:
        raise
Exemple #2
0
def start_threads():
    global threads
    app.logger.info("STARTING THREADS")

    # Start threads
    btc_thread1 = BackgroundThread(update_bitcoin_main_info_thread, 10)
    btc_thread1.start()
    threads.append(btc_thread1)
    btc_thread2 = BackgroundThread(update_bitcoin_other_info_thread, 30)
    btc_thread2.start()
    threads.append(btc_thread2)
    electrs_info_thread = BackgroundThread(update_electrs_info_thread, 60)
    electrs_info_thread.start()
    threads.append(electrs_info_thread)
    lnd_thread = BackgroundThread(update_lnd_info_thread, 60)
    lnd_thread.start()
    threads.append(lnd_thread)
    drive_thread = BackgroundThread(update_device_info, 60)
    drive_thread.start()
    threads.append(drive_thread)
    public_ip_thread = BackgroundThread(find_public_ip, 60*60*12) # 12-hour repeat
    public_ip_thread.start()
    threads.append(public_ip_thread)

    app.logger.info("STARTED {} THREADS".format(len(threads)))
Exemple #3
0
def start_threads():
    global threads
    app.logger.info("STARTING THREADS")

    # Start threads
    btc_thread1 = BackgroundThread(
        update_bitcoin_main_info_thread,
        60)  # Restart after 60, thread manages timing
    btc_thread1.start()
    threads.append(btc_thread1)
    btc_thread2 = BackgroundThread(update_bitcoin_other_info_thread, 60)
    btc_thread2.start()
    threads.append(btc_thread2)
    electrs_info_thread = BackgroundThread(update_electrs_info_thread, 60)
    electrs_info_thread.start()
    threads.append(electrs_info_thread)
    lnd_thread = BackgroundThread(update_lnd_info_thread, 60)
    lnd_thread.start()
    threads.append(lnd_thread)
    drive_thread = BackgroundThread(update_device_info, 60)
    drive_thread.start()
    threads.append(drive_thread)
    public_ip_thread = BackgroundThread(find_public_ip,
                                        60 * 60 * 12)  # 12-hour repeat
    public_ip_thread.start()
    threads.append(public_ip_thread)
    dmesg_thread = BackgroundThread(
        monitor_dmesg, 60)  # Runs forever, restart after 60 if it fails
    dmesg_thread.start()
    threads.append(dmesg_thread)

    app.logger.info("STARTED {} THREADS".format(len(threads)))
Exemple #4
0
    }
    return render_template('state.html', **templateData), 500

# Disable browser caching
@app.after_request
def set_response_headers(response):
    #response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
    #response.headers['Pragma'] = 'no-cache'
    #response.headers['Expires'] = '0'
    return response

if __name__ == "__main__":
    signal.signal(signal.SIGTERM, on_shutdown)
    signal.signal(signal.SIGINT, on_shutdown)
    btc_thread1 = BackgroundThread(update_bitcoin_main_info_thread, 60)
    btc_thread1.start()
    btc_thread2 = BackgroundThread(update_bitcoin_other_info_thread, 60)
    btc_thread2.start()
    electrs_info_thread = BackgroundThread(update_electrs_info_thread, 60)
    electrs_info_thread.start()
    lnd_thread = BackgroundThread(update_lnd_info_thread, 60)
    lnd_thread.start()
    drive_thread = BackgroundThread(update_device_info, 60)
    drive_thread.start()
    public_ip_thread = BackgroundThread(find_public_ip, 60*60*3) # 3-hour repeat
    public_ip_thread.start()
    checkin_thread = BackgroundThread(check_in, 60*60*24) # Per-day checkin
    checkin_thread.start()

    my_logger = logging.getLogger('FlaskLogger')
    my_logger.setLevel(logging.DEBUG)