Inappropriate ioctl for device when #36
Unanswered
NikosAlexandris
asked this question in
Q&A
Replies: 1 comment
-
Hey, thanks for the report. I was able to reproduce the described error: ```bash exec="true" result="ansi" source="material-block"
python <<EOF
import os
print(os.get_terminal_size())
EOF
``` I observed that it is not specific to Markdown Exec: % python -c 'import os; print(os.get_terminal_size())' | cat
Traceback (most recent call last):
File "<string>", line 1, in <module>
OSError: [Errno 25] Inappropriate ioctl for device Instead of % python -c 'import shutil; print(shutil.get_terminal_size())' | cat
os.terminal_size(columns=80, lines=24) I found this by reading the docstring of the os method: >>> import os
>>> help(os.get_terminal_size)
Help on built-in function get_terminal_size in module posix:
get_terminal_size(...)
Return the size of the terminal window as (columns, lines).
The optional argument fd (default standard output) specifies
which file descriptor should be queried.
If the file descriptor is not connected to a terminal, an OSError
is thrown.
This function will only be defined if an implementation is
available for this system.
shutil.get_terminal_size is the high-level function which should
normally be used, os.get_terminal_size is the low-level implementation. You can see how shutil achieves this with Or you could catch the error and use default values: try:
terminal_columns, _ = os.get_terminal_size()
except OSError:
terminal_columns = 80 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to execute a python script, like :
where one of the outputs, of it, is a uniplot. The script fails to complete, however, before plotting when it tries to fetch the size of the terminal using Python's
os.get_terminal_size()
and the error is :Can I work-around this
[Errno 25] Inappropriate ioctl for device
?Beta Was this translation helpful? Give feedback.
All reactions