OSError when piping
Austreelis opened this issue · comments
When piping the output of td
, a call to os.get_terminal_size()
raises an OSError
that is never caucht:
Demonstration with a little snippet:
import os
print("foo")
print(os.get_terminal_size())
This works fine when running the script, but running python example.py | grep foo
throws:
Traceback (most recent call last):
File "/tmp/example.py", line 5, in <module>
print(os.get_terminal_size())
foo
OSError: [Errno 25] Inappropriate ioctl for device
This looks quite easy to solve, so I already forked and will start working on it asap.
FYI, I am trying to display my todos in conky, using this project to convert ansi color codes to conky color commands by piping td
into ansito -
, and give that to conky to display as text.
Ah nice! Thanks for submitting the issue.
I made the fix in https://github.com/darrikonn/td-cli/pull/11/files -> so you can upgrade td-cli with pip install --upgrade td-cli
. Version 1.2.4
contains the fix :).
Thanks again!