ihabunek / toot

toot - Mastodon CLI & TUI
GNU General Public License v3.0
1.17k stars 110 forks source link

NameError: name 'fcntl' is not defined #205

Open mikwee opened 2 years ago

mikwee commented 2 years ago

When I try to open the TUI, I get this error:

Traceback (most recent call last):
  File "C:\Users\mikwee\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\mikwee\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\Scripts\toot.exe\__main__.py", line 7, in <module>
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\console.py", line 560, in main
    run_command(app, user, command_name, args)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\console.py", line 542, in run_command
    return fn(app, user, parsed_args)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\commands.py", line 347, in tui
    TUI.create(app, user).run()
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\tui\app.py", line 78, in create
    loop = urwid.MainLoop(
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\urwid\main_loop.py", line 115, in __init__
    screen = raw_display.Screen()
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\urwid\raw_display.py", line 92, in __init__
    fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
NameError: name 'fcntl' is not defined

What's happening?

ihabunek commented 2 years ago

fcntl is not supported on windows. If you want to run toot tui you can try using WSL, although it might be overkill if that's the only thing you're using it for. It might also work in cygwin, not sure, don't have a windows box to test.

igalic commented 2 years ago

Is there no file handling library in Python that abstracts between platforms?

ihabunek commented 2 years ago

fnctl is used by urwid, which is used to build the TUI. I haven't really looked into how it could be made to work on windows.

nausicaa-rose commented 2 years ago

I think it would require switching from urwid to a library that supports Windows terminals as well, like asciimatics, blessed, prompt_toolkit, or textual.

If that's a direction you're willing to go, I'd be happy to work on it. I'd like to be able to use the TUI on Windows without resorting to WSL.

ihabunek commented 2 years ago

@wtee It is something I have considered. I tried blessed and prompt_toolkit and wasn't enamored. I liked the look of textual but it's very early in development, and needs a bit more time to mature. I'll probably be making incremental improvements to urwid variant for a little while longer. I'll check out asciimatics too, since I haven't looked at it yet.

drbean commented 8 months ago

version 0.42.0 works like a charm in cygwin on Windows 10. Installing with ' python -m pip install toot==0.42' hung installing urwid, so I just installed urwid separately.

If I knew it was going to be this easy with cygwin, I would have installed it whenI forked it last year, 60 commits ago.