torproject / nyx

Command-line monitor for Tor.
https://nyx.torproject.org/
GNU General Public License v3.0
123 stars 26 forks source link

FreeBSD 14.1 - nyx 2.1.0_2 crashes after pressing s key or down arrow (and probably other keys) #74

Closed craig0100 closed 3 months ago

craig0100 commented 3 months ago

Traceback (most recent call last):c.sample for its options). File "/usr/local/bin/nyx", line 33, in sys.exit(load_entry_point('nyx==2.1.0', 'console_scripts', 'nyx')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/nyx/init.py", line 176, in main nyx.starter.main() File "/usr/local/lib/python3.11/site-packages/stem/util/conf.py", line 289, in wrapped return func(*args, config = config, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/nyx/starter.py", line 128, in main nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False) File "/usr/local/lib/python3.11/site-packages/nyx/curses.py", line 219, in start curses.wrapper(_wrapper) File "/usr/local/lib/python3.11/curses/init.py", line 94, in wrapper return func(stdscr, args, **kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/nyx/curses.py", line 217, in _wrapper function() File "/usr/local/lib/python3.11/site-packages/nyx/init.py", line 243, in draw_loop keybinding.handle(key) File "/usr/local/lib/python3.11/site-packages/nyx/panel/init.py", line 81, in handle if inspect.getargspec(self._action).args == ['key']: ^^^^^^^^^^^^^^^^^^ AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'? root@ande:~ #

The error you’re encountering is due to the removal of the inspect.getargspec() function in Python 3.11. This function has been deprecated and replaced by inspect.getfullargspec() or inspect.signature()12.

To fix this issue in Nyx, you can replace all instances of inspect.getargspec() with inspect.getfullargspec(). Here’s a quick way to do it:

sudo find /usr/local/lib/python3.11/site-packages/nyx -type f -exec sed -i '' 's/getargspec/getfullargspec/g' {} +

This command should correctly replace all instances of getargspec with getfullargspec in the specified directory.

After running this command, try launching Nyx again to see if the issue is resolved.

If you encounter any further issues, feel free to ask! Are you using Nyx for monitoring a specific Tor relay, or is it part of a larger project?

Source: Conversation with Copilot, 8/2/2024 (1) Equivalent function of getargspec in python 3.11 - Stack Overflow. https://stackoverflow.com/questions/78475272/equivalent-function-of-getargspec-in-python-3-11. (2) Nyx incompatible with Python 3.11+ (getargspec error) #63 - GitHub. https://github.com/torproject/nyx/issues/63. (3) python 3.x - Sqlacodegen showing Argspec not found - Stack Overflow. https://stackoverflow.com/questions/76298747/sqlacodegen-showing-argspec-not-found. (4) Python argcomplete is broken for Python 3.11 - GitLab. https://gitlab.com/kicad/code/kicad/-/issues/14155.

craig0100 commented 3 months ago

This worked for me. Just wanted to share in case anyone else runs into this.