markqvist / NomadNet

Communicate Freely
GNU General Public License v3.0
1.23k stars 47 forks source link

Windows: NomadNet crashes when attempting to view logs #57

Closed icejuice-enjoyer closed 3 months ago

icejuice-enjoyer commented 4 months ago

Describe the Bug When clicking the [ Log ] tab at the top of the NomadNet TUI on Windows systems, the program crashes.

To Reproduce In a Windows Command Prompt or PowerShell session with Python 3 installed:

1) Install NomadNet through pip py -m pip install nomadnet 2) Launch NomadNet nomadnet 3) Click on the [ Log ] tab at the top of the TUI.

Expected Behavior The log screen displays as normal.

Logs & Screenshots When crashing, this is printed to the terminal's output:

'stty' is not recognized as an internal or external command, operable program or batch file.
'stty' is not recognized as an internal or external command, operable program or batch file.
'stty' is not recognized as an internal or external command, operable program or batch file.

System Information

eddebc commented 3 months ago

Managed to reproduce and spew out the traceback:

Traceback (most recent call last):
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\nomadnet.py", line 51, in main
    program_setup(configarg, rnsconfigarg, daemon, console)
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\nomadnet.py", line 11, in program_setup
    app = nomadnet.NomadNetworkApp(
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\NomadNetworkApp.py", line 386, in __init__
    nomadnet.ui.spawn(self.uimode)
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\__init__.py", line 29, in spawn
    return TextUI()
           ^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\TextUI.py", line 211, in __init__
    self.loop.run()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\main_loop.py", line 337, in run
    self._run()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\main_loop.py", line 439, in _run
    self.event_loop.run()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\select_loop.py", line 182, in run
    self._loop()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\select_loop.py", line 229, in _loop
    record.data()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\display\_win32_raw_display.py", line 172, in wrapper
    return self.parse_input(event_loop, callback, self.get_available_raw_input())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\display\_raw_display_base.py", line 488, in parse_input
    callback(decoded_codes, raw_codes)
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\main_loop.py", line 466, in _update
    self.process_input(keys)
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\event_loop\main_loop.py", line 575, in process_input
    if hasattr(self._topmost_widget, "mouse_event") and self._topmost_widget.mouse_event(
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\textui\Main.py", line 74, in mouse_event
    return super(MainFrame, self).mouse_event(size, event, button, col, row, focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\widget\frame.py", line 550, in mouse_event
    return self.header.mouse_event((maxcol,), event, button, col, row, focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\widget\columns.py", line 1152, in mouse_event
    return w.mouse_event(w_size, event, button, col - x, row, focus)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\widget\wimp.py", line 785, in mouse_event
    self._emit("click")
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\widget\widget.py", line 310, in _emit
    signals.emit_signal(self, name, self, *args)
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\signals.py", line 298, in emit
    result |= self._call_callback(callback, user_arg, weak_args, user_args, args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\signals.py", line 322, in _call_callback
    return bool(callback(*args))
                ^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\textui\Main.py", line 118, in show_log
    self.sub_displays.log_display.show()
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\textui\Log.py", line 21, in show
    self.log_term = LogTerminal(self.app)
                    ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\nomadnet\ui\textui\Log.py", line 36, in __init__
    self.log_term = urwid.Terminal(
                    ^^^^^^^^^^^^^^
  File "C:\Users\Docker\debugnomandnet\venv\Lib\site-packages\urwid\__init__.py", line 346, in __getattr__
    raise AttributeError(f"{name} not found in {__package__}")
AttributeError: Terminal not found in urwid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Docker\AppData\Local\Programs\Python\Python312\Lib\cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Pdb' object has no attribute 'do_print'. Did you mean: 'do_cont'?

Looks like this is related:
https://github.com/urwid/urwid?tab=readme-ov-file#windows-support-notes
Terminal is not supported in Windows

eddebc commented 3 months ago

PR for this
https://github.com/markqvist/NomadNet/pull/58

markqvist commented 3 months ago

Fixed by #58