yashsinghcodes / wik

wik is use to get information about anything on the shell using Wikipedia.
https://pypi.org/project/wik/
MIT License
616 stars 21 forks source link

Unable to use a pager #4

Closed pmopmo closed 2 years ago

pmopmo commented 2 years ago

It's not possible to pipe output of fetch to a file or a pager

fetch -i mallard | less -R

Traceback (most recent call last):
  File "/usr/local/bin/fetch", line 11, in <module>
    load_entry_point('yashsinghcodes==0.1', 'console_scripts', 'fetch')()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/usr/local/lib/python3.6/site-packages/yashsinghcodes-0.1-py3.6.egg/fetch/__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/usr/local/lib/python3.6/site-packages/yashsinghcodes-0.1-py3.6.egg/fetch/fetch.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/usr/local/lib/python3.6/site-packages/yashsinghcodes-0.1-py3.6.egg/fetch/info.py", line 18, in <module>
OSError: [Errno 25] Inappropriate ioctl for device

In fetch/info.py I changed

width,height = os.get_terminal_size()

to

try:
    width,height = os.get_terminal_size()
except OSError:
    width = 120
    height = 80

to get it to work

yashsinghcodes commented 2 years ago

Thanks for reporting the issue. I have used your quick fix for OSError and will look deep in the issue for some better fix.