Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jupyter notebook usage: Replace stty with shutil.get_terminal_size #19

Merged
merged 5 commits into from
Jul 25, 2018

Conversation

jdanbrown
Copy link
Contributor

@jdanbrown jdanbrown commented Jun 13, 2018

In an ipykernel (e.g. when in a jupyter notebook), install_extras emits a spurious error to stderr:

$ jupyter console
>>> import prettyprinter; prettyprinter.install_extras(warn_on_error=False)
stty: 'standard input': Inappropriate ioctl for device

The problem appears to be the usage of the stty shell command:

>>> import os; os.popen('stty size', 'r').read()
stty: 'standard input': Inappropriate ioctl for device
''

Replacing uses of stty with the builtin shutil.get_terminal_size() appears to avoid this:

>>> import shutil; shutil.get_terminal_size()
os.terminal_size(columns=133, lines=75)

@jdanbrown
Copy link
Contributor Author

Sorry for the multiple commits, this is ready for review.

@tommikaikkonen
Copy link
Owner

Thanks! LGTM. Sorry for the delay in merging this.

@tommikaikkonen tommikaikkonen merged commit 537bc96 into tommikaikkonen:master Jul 25, 2018
@tommikaikkonen
Copy link
Owner

Released to PyPi in https://github.com/tommikaikkonen/prettyprinter/releases/tag/v0.14.0!

@jdanbrown jdanbrown deleted the patch-1 branch July 25, 2018 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants