Beispiel #1
0
def hold(args: List[str]) -> None:
    import subprocess
    ret = 1
    try:
        ret = subprocess.Popen(args[1:]).wait()
    except KeyboardInterrupt:
        pass
    except FileNotFoundError:
        print(f'Could not find {args[1]!r} to execute', file=sys.stderr)
    except Exception as e:
        print(e, file=sys.stderr)
    from kitty.utils import hold_till_enter
    hold_till_enter()
    raise SystemExit(ret)
Beispiel #2
0
def real_main(args: List[str]) -> None:
    msg = 'Show an error message'
    cli_opts, items = parse_args(args[1:],
                                 OPTIONS,
                                 '',
                                 msg,
                                 'hints',
                                 result_class=ErrorCLIOptions)
    data = json.loads(sys.stdin.buffer.read())
    error_message = data['msg']
    if cli_opts.title:
        print(styled(cli_opts.title, fg_intense=True, fg='red', bold=True))
        print()
    print(error_message, flush=True)
    if data.get('tb'):
        import select
        from kittens.tui.operations import init_state, set_cursor_visible
        fd, original_termios = open_tty()
        msg = '\n\r\x1b[1;32mPress e to see detailed traceback or any other key to exit\x1b[m'
        write_all(fd, msg)
        write_all(
            fd,
            init_state(alternate_screen=False, kitty_keyboard_mode=False) +
            set_cursor_visible(False))
        with no_echo(fd):
            termios.tcdrain(fd)
            while True:
                rd = select.select([fd], [], [])[0]
                if not rd:
                    break
                q = os.read(fd, 1)
                if q in b'eE':
                    break
                return
    if data.get('tb'):
        tb = data['tb']
        for ln in tb.splitlines():
            print('\r\n', ln, sep='', end='')
        print(flush=True)
    hold_till_enter()
Beispiel #3
0
def hold(args: List[str]) -> None:
    import subprocess
    ret = subprocess.Popen(args[1:]).wait()
    from kitty.utils import hold_till_enter
    hold_till_enter()
    raise SystemExit(ret)