Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpterm fails when reading from stdin #14

Open
mattiasb opened this issue Sep 2, 2024 · 1 comment
Open

jpterm fails when reading from stdin #14

mattiasb opened this issue Sep 2, 2024 · 1 comment

Comments

@mattiasb
Copy link

mattiasb commented Sep 2, 2024

Piping some simple JSON like [] to jpterm fails like this:

$ echo '[]' | jpterm
Traceback (most recent call last):
  File "/home/mattiasb/.local/bin/jpterm", line 6, in <module>
    jpterm.main()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/jpterm.py", line 231, in main
    display.main(screen=screen)
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/jpterm.py", line 148, in main
    self.loop.run()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/main_loop.py", line 790, in run
    self._loop()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/main_loop.py", line 827, in _loop
    self._watch_files[fd]()
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/raw_display.py", line 417, in <lambda>
    event_loop, callback, self.get_available_raw_input())
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/raw_display.py", line 449, in get_available_raw_input
    codes = self._get_gpm_codes() + self._get_keyboard_codes()
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/raw_display.py", line 523, in _get_keyboard_codes
    code = self._getch_nodelay()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/raw_display.py", line 661, in _getch_nodelay
    return self._getch(0)
           ^^^^^^^^^^^^^^
  File "/home/mattiasb/.local/pipx/venvs/jmespath-community-terminal/lib64/python3.12/site-packages/urwid/raw_display.py", line 571, in _getch
    return ord(os.read(fd, 1))
           ^^^^^^^^^^^^^^^^^^^
TypeError: ord() expected a character, but string of length 0 found

This was supposedly fixed by #4 but it seems it was not enough.

How to reproduce

To make sure this wasn't something weird on my machine I reproduced
it in a fresh Ubuntu 24.04 container. Swap podman for docker if you
prefer. It should work the same.

$ podman run --rm -it                                              \
       --env DEBIAN_FRONTEND=noninteractive                        \
       --env PATH='/root/.local/bin:/usr/sbin:/usr/bin:/sbin:/bin' \
       docker.io/ubuntu:24.04                                      \
       /bin/bash -c " apt update                                   \
                    ; apt upgrade -y                               \
                    ; apt install -y python-is-python3 pipx        \
                    ; pipx install jmespath-community-terminal     \
                    ; echo '[]' | jpterm                           \
                    "
@kit494way
Copy link
Contributor

The fix has not yet been released.
Try installing from the repository.

pipx install git+https://github.com/jmespath-community/jmespath.terminal.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants