gautamkrishnar / socli

Stack overflow command line client. Search and browse stack overflow without leaving the terminal :computer:
https://pypi.python.org/pypi/socli
BSD 3-Clause "New" or "Revised" License
1.1k stars 218 forks source link

Fcntl not found issue in windows #185

Open dondon1993 opened 4 years ago

dondon1993 commented 4 years ago

Hi,

I'm not sure whether this issue has been brought up. I tried using socli in windows terminal. When I typed 'socli -iq html error 404' and made a selection, it just outputs 'Exiting'. I turned on the DEBUG mode and found the error message:

Error name: Name not found globally.

Description: name 'fcntl' is not defined

Traceback (most recent call last):
  File "E:\ANACONDA\lib\site-packages\socli-4.0-py3.6.egg\socli\search.py", line 193, in socli_interactive_windows
    socli.printer.display_results(so_url + question_local_url[op - 1])
  File "E:\ANACONDA\lib\site-packages\socli-4.0-py3.6.egg\socli\printer.py", line 219, in display_results
    tui.MAIN_LOOP = tui.EditedMainLoop(tui.question_post, palette)
  File "E:\ANACONDA\lib\site-packages\urwid\main_loop.py", line 115, in __init__
    screen = raw_display.Screen()
  File "E:\ANACONDA\lib\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

It seems due to windows doesn't natively support urwid library. I don't know whether we have a solution for this?

github-actions[bot] commented 4 years ago

Thanks for reporting your first issue to SoCLI. We really value your feedback.

hedyhli commented 4 years ago

Yes there is problems with running socli on Windows. As mentioned in urwid docs, it needs a Unix platform. But I don't think we have a solution yet

dondon1993 commented 4 years ago

What about switching the rendering in command line console to a library which supports both windows and Unix platform?

hedyhli commented 4 years ago

Yes we could try replacing urwid with something like python prompt toolkit or curtsies, @gautamkrishnar what do you think about this?

gautamkrishnar commented 4 years ago

@hedythedev socli interactive mode doesn't support windows cmd. As of now urwid works as intended on all other platforms. This error is happening due to the recent refactoring. Using the code available for socli_interactive_windows in the old version https://github.com/gautamkrishnar/socli/blob/master-backup/socli/socli.py#L620 will fix this issue.