Repository navigation
Use pymacos instead of pync for the nc alerter - #1960
Open
JeanExtreme002 wants to merge 2 commits into
Open
JeanExtreme002 wants to merge 2 commits into
JeanExtreme002 wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
ncalerter relies on pync, which hasn't had a release since 2.0.3 (May 2018). pync works by shelling out to theterminal-notifierapp it bundles, and that binary is Intel-only:On Apple silicon it only runs under Rosetta. Apple has said Rosetta stays available as a general-purpose tool only through macOS 27, so the alerter has a deadline. Also, when notifications are turned off, pync's alerts vanish without any error.
This switches the alerter to pymacos, a pure-Python library with no dependencies:
pync.notify(message=..., title="SimpleMonitor")becomesmacos.notify(message, title="SimpleMonitor"). It posts through AppleScript, with the text passed as arguments, so quotes and emoji in monitor names need no escaping.alerter_logger.exception("Couldn't send notification")and doesn't stop the run.pyproject.toml:pyncis replaced bypymacos = {version = "^1.19", platform = "darwin"}.poetry.lockwas regenerated with the same Poetry version (2.4.1), so the diff is just that swap and the content hash.docs/alerters/nc.rst: notes the Script Editor attribution and the logged error.tests/test_nc.py: checks that a failure is notified with the right title, that a notification error is logged and not raised, and thatdry_runsends nothing. These tests fail against the current pync code.Disclosure: I'm the author of pymacos.
Checked locally:
pytest testspasses (189 tests), andruff check,ruff format --checkandmypyare clean.MonitorFailnameddisk "backup" café 🚀, with a stubosascripton PATH so no real notification was posted. pymacos called it with the messageMonitor disk "backup" café 🚀 on <host> failedand the titleSimpleMonitor, unchanged.