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: use shutil.get_terminal_size instead of os.get_terminal_size #99

Merged
merged 1 commit into from
Oct 4, 2020

Conversation

chrisburr
Copy link
Member

@chrisburr chrisburr commented Oct 3, 2020

os.get_terminal_size fail when there is no terminal connected (e.g. CI):

+ hist --help
Traceback (most recent call last):
  File "/home/conda/staged-recipes/build_artifacts/hist_1601700363608/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/bin/hist", line 11, in <module>
    sys.exit(main())
  File "/home/conda/staged-recipes/build_artifacts/hist_1601700363608/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/lib/python3.7/site-packages/hist/classichist.py", line 21, in main
    default=os.get_terminal_size()[0],
OSError: [Errno 25] Inappropriate ioctl for device

Using shutil.get_terminal_size instead allows a fallback to be used instead of crashing.

See this build log from conda-forge for a demonstration:
https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=217306&view=logs&jobId=10bda42a-d420-5c28-a43f-bc4e66405e5c&j=10bda42a-d420-5c28-a43f-bc4e66405e5c&t=bef775d0-a1a2-55a3-9721-17147029baf0

chrisburr added a commit to chrisburr/staged-recipes that referenced this pull request Oct 3, 2020
@LovelyBuggies LovelyBuggies merged commit 4d7f575 into scikit-hep:master Oct 4, 2020
@LovelyBuggies LovelyBuggies changed the title Use shutil.get_terminal_size instead of os.get_terminal_size fix: use shutil.get_terminal_size instead of os.get_terminal_size Oct 4, 2020
@LovelyBuggies
Copy link
Collaborator

Thanks :)

@chrisburr chrisburr deleted the hist-no-term branch October 4, 2020 04:14
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.

2 participants