Exemple #1
0
def build_cluster_status():
    ctx = context()
    build_cluster_status_command()
    # building pods container
    bad_pod_text_control = FormattedTextControl(
        text=lambda: CONTENT_VENDERER['pod_text'])
    bad_pod_win = Win(content=bad_pod_text_control)
    bad_pod_title = ctx.obj['watch_bad_pod_title']
    bad_pod_container = HSplit([
        Win(
            height=1,
            content=Title(bad_pod_title),
        ),
        bad_pod_win,
    ])
    # building nodes container
    bad_node_text_control = FormattedTextControl(
        text=lambda: CONTENT_VENDERER['node_text'])
    bad_node_window = Win(content=bad_node_text_control)
    bad_node_container = HSplit([
        Win(
            height=1,
            content=Title('bad nodes'),
        ),
        bad_node_window,
    ])
    parts = [bad_pod_container, bad_node_container]
    global_urls = ctx.obj.get('global_urls')
    if global_urls:
        ingress_text_control = FormattedTextControl(
            text=lambda: CONTENT_VENDERER['ingress_text'])
        ingress_window = Win(content=ingress_text_control,
                             height=lambda: tell_screen_height(0.4))
        ingress_container = HSplit([
            Win(height=1, content=Title('bad url requests')),
            ingress_window,
        ])
        parts.append(ingress_container)

    # building root container
    root_container = HSplit(parts)
    kb = KeyBindings()

    @kb.add('c-c', eager=True)
    @kb.add('c-q', eager=True)
    def _(event):
        event.app.exit()

    app = Application(
        key_bindings=kb,
        layout=Layout(root_container),
        full_screen=True,
    )
    app.create_background_task(refresh_admin_content())
    return app
Exemple #2
0
def _(event: KeyPressEvent) -> None:
    event.app.exit()


application = Application(
    layout=Layout(root_container, focused_element=left_window),
    key_bindings=kb,
    mouse_support=True,
    full_screen=True,
)

o = StringIO()


async def tick():
    for i in range(100):
        print("tick", i, file=o)
        await asyncio.sleep(0.5)


async def redraw():
    while True:
        right_buffer.text = o.getvalue()
        right_buffer.auto_down()
        await asyncio.sleep(0.6)


application.create_background_task(tick())
application.create_background_task(redraw())
application.run()
Exemple #3
0
def build_app_status():
    ctx = context()
    build_app_status_command()
    # building pods container
    pod_text_control = FormattedTextControl(
        text=lambda: CONTENT_VENDERER['pod_text'])
    pod_win = Win(content=pod_text_control)
    pod_title = ctx.obj['watch_pod_title']
    pod_container = HSplit([
        Win(
            height=1,
            content=Title(pod_title),
        ),
        pod_win,
    ])
    # building top container
    top_text_control = FormattedTextControl(
        text=lambda: CONTENT_VENDERER['top_text'])
    top_win = Win(content=top_text_control)
    top_title = ctx.obj['watch_top_title']
    top_container = HSplit([
        Win(
            height=1,
            content=Title(top_title),
        ),
        top_win,
    ])
    # building events container
    events_text_control = FormattedTextControl(
        text=lambda: CONTENT_VENDERER['event_text'])
    events_window = Win(content=events_text_control)
    events_container = HSplit([
        Win(
            height=1,
            content=Title('events and messages for pods in weird states'),
        ),
        events_window,
    ])
    parts = [pod_container, top_container, events_container]
    # building ingress container
    urls = ctx.obj.get('urls')
    if urls:
        ingress_text_control = FormattedTextControl(
            text=lambda: CONTENT_VENDERER['ingress_text'])
        ingress_window = Win(content=ingress_text_control,
                             height=len(urls) + 3)
        ingress_container = HSplit([
            Win(height=1, content=Title('url requests')),
            ingress_window,
        ])
        parts.append(ingress_container)

    # building root container
    root_container = HSplit(parts)
    kb = KeyBindings()

    @kb.add('c-c', eager=True)
    @kb.add('c-q', eager=True)
    def _(event):
        event.app.exit()

    app = Application(
        key_bindings=kb,
        layout=Layout(root_container),
        full_screen=True,
    )
    app.create_background_task(refresh_content())
    return app