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

catch unhandled OSError when serial port in use #734

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

dudash
Copy link
Contributor

@dudash dudash commented Feb 8, 2025

Existing crash:

Traceback (most recent call last):
  File "/opt/homebrew/bin/meshtastic", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/meshtastic/__main__.py", line 1988, in main
    common()
  File "/opt/homebrew/lib/python3.9/site-packages/meshtastic/__main__.py", line 1242, in common
    client = meshtastic.serial_interface.SerialInterface(
  File "/opt/homebrew/lib/python3.9/site-packages/meshtastic/serial_interface.py", line 52, in __init__
    with open(self.devPath, encoding="utf8") as f:
OSError: [Errno 16] Resource busy: '/dev/cu.usbserial-0001'

with updated catch:

OS Error:
  The serial device couldn't be opened, it might be in use by another process.
  Please close any applications or webpages that may be using the device and try again.

Original error: [Errno 16] Resource busy: '/dev/cu.usbserial-0001'

@CLAassistant
Copy link

CLAassistant commented Feb 8, 2025

CLA assistant check
All committers have signed the CLA.

@dudash
Copy link
Contributor Author

dudash commented Feb 8, 2025

Could even include something like https://github.com/Textualize/rich to pretty up CLI output with color. But figured that'd be a better as a larger feature request PR.

@ianmcorvidae
Copy link
Contributor

We're using print_color in some places, but could probably expand that and if rich provides something more beneficial that might be okay to switch to. The colorization stuff is currently behind the cli extras as well, so it won't need to be installed on more limited machines/within more limited packaging ecosystems.

@ianmcorvidae
Copy link
Contributor

This looks good to me! Thanks for the PR.

@ianmcorvidae ianmcorvidae merged commit 5837bd0 into meshtastic:master Feb 18, 2025
9 checks passed
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 60.26%. Comparing base (fc3b81d) to head (e2fe359).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
meshtastic/__main__.py 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #734      +/-   ##
==========================================
- Coverage   60.35%   60.26%   -0.10%     
==========================================
  Files          24       24              
  Lines        3970     3976       +6     
==========================================
  Hits         2396     2396              
- Misses       1574     1580       +6     
Flag Coverage Δ
unittests 60.26% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

3 participants