Ejemplo n.º 1
0
def main(_, options, reg):
    screen = None
    if options.display == 'html':
        TREE_EXPAND_DEPTH[0] = -1  # expand tree fully
        screen = html_fragment.HtmlGenerator()
        screen.set_terminal_properties(256)
        screen.register_palette(TuiApp.palette)
        html_fragment.screenshot_init(
            [tuple(map(int, options.v_term_size.split(',')))], [])

    try:
        TuiApp(reg, screen=screen).main()

        if options.display == 'html':
            for fragment in html_fragment.screenshot_collect():
                print(fragment)
    except KeyboardInterrupt:
        pass
Ejemplo n.º 2
0
def main(_, options: 'Values', workflow_id: str) -> None:
    workflow_id, *_ = parse_id(
        workflow_id,
        constraint='workflows',
    )
    screen = None
    if options.display == 'html':
        TREE_EXPAND_DEPTH[0] = -1  # expand tree fully
        screen = html_fragment.HtmlGenerator()
        screen.set_terminal_properties(256)
        screen.register_palette(TuiApp.palette)
        html_fragment.screenshot_init(
            [tuple(map(int, options.v_term_size.split(',')))], [])

    try:
        TuiApp(workflow_id, screen=screen).main()

        if options.display == 'html':
            for fragment in html_fragment.screenshot_collect():
                print(fragment)
    except KeyboardInterrupt:
        pass
Ejemplo n.º 3
0
def main(slidespec):
    loop = SlideLoop(slidespec)
    palette = list(loop.palette)
    slides = loop.slides
    size = 41, 17
    generator = html_fragment.HtmlGenerator()
    generator.set_terminal_properties(256)
    generator.register_palette(palette)
    for slide in slides:
        widget = slide(getattr(slide, 'subslide_count', 0))
        for i in range(40):
            canvas = widget.render(size)
        generator.draw_screen(size, canvas)

    outfile = sys.stdout
    templ_start, templ_end = template.split('{}')
    outfile.write(templ_start)
    for fragment in html_fragment.screenshot_collect():
        outfile.write('<div class="slide">')
        outfile.write(fragment)
        outfile.write('</div>')
    outfile.write(templ_end)
    outfile.flush()
    # Using the same label_width allows the bars to line up.
    bar1 = TimedProgressBar('normal', 'complete', label='Current File',
                            label_width=15, units='MB', done=10)
    bar2 = TimedProgressBar('normal', 'complete', label='Overall',
                            label_width=15, units='MB', done=100)

    # Advance the second bar
    bar2.add_progress(40)

    footer = uw.Text('q to exit, any other key adds to progress')
    progress = uw.Frame(uw.ListBox([bar1, uw.Divider(), bar2]), footer=footer)

    # Pressing a key other that 'q' advances the progress bars by 1
    # Calling add_progress() also updates the displayed rate and time
    # remaining.
    def keypress(key):
        if key in ('q', 'Q'):
            raise uw.ExitMainLoop()
        else:
            bar2.add_progress(1)
            if bar1.add_progress(1) and bar2.current < bar2.done:
                bar1.reset()

    loop = uw.MainLoop(progress, palette, unhandled_input=keypress)
    loop.run()

    if take_screenshot:
        for i, s in enumerate(screenshot_collect()):
            with open('screenshot-{}.html'.format(i), 'w') as f:
                f.write(s)
                            'complete',
                            label='Overall',
                            label_width=15,
                            units='MB',
                            done=100)

    # Advance the second bar
    bar2.add_progress(40)

    footer = uw.Text('q to exit, any other key adds to progress')
    progress = uw.Frame(uw.ListBox([bar1, uw.Divider(), bar2]), footer=footer)

    # Pressing a key other that 'q' advances the progress bars by 1
    # Calling add_progress() also updates the displayed rate and time
    # remaining.
    def keypress(key):
        if key in ('q', 'Q'):
            raise uw.ExitMainLoop()
        else:
            bar2.add_progress(1)
            if bar1.add_progress(1) and bar2.current < bar2.done:
                bar1.reset()

    loop = uw.MainLoop(progress, palette, unhandled_input=keypress)
    loop.run()

    if take_screenshot:
        for i, s in enumerate(screenshot_collect()):
            with open('screenshot-{}.html'.format(i), 'w') as f:
                f.write(s)