Skip to content

Use pymacos instead of pync for the nc alerter - #1960

Open
JeanExtreme002 wants to merge 2 commits into
jamesoff:developfrom
JeanExtreme002:nc-alerter-pymacos
Open

JeanExtreme002 wants to merge 2 commits into
jamesoff:developfrom
JeanExtreme002:nc-alerter-pymacos

Conversation

@JeanExtreme002

@JeanExtreme002 JeanExtreme002 commented Oct 2, 2026 •

Copy link
Copy Markdown

The nc alerter relies on pync, which hasn't had a release since 2.0.3 (May 2018). pync works by shelling out to the terminal-notifier app it bundles, and that binary is Intel-only:

$ file pync/vendor/terminal-notifier-2.0.0/terminal-notifier.app/Contents/MacOS/terminal-notifier
Mach-O 64-bit executable x86_64

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") becomes macos.notify(message, title="SimpleMonitor"). It posts through AppleScript, with the text passed as arguments, so quotes and emoji in monitor names need no escaping.
  • If notifications are turned off for the app that posts them (Script Editor), pymacos raises instead of macOS dropping the alert. Following the other alerters, the failure is logged with alerter_logger.exception("Couldn't send notification") and doesn't stop the run.
  • pyproject.toml: pync is replaced by pymacos = {version = "^1.19", platform = "darwin"}. poetry.lock was 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 that dry_run sends nothing. These tests fail against the current pync code.

Disclosure: I'm the author of pymacos.

Checked locally:

  • On macOS (Apple silicon), pytest tests passes (189 tests), and ruff check, ruff format --check and mypy are clean.
  • I ran the real alerter with a real MonitorFail named disk "backup" café 🚀, with a stub osascript on PATH so no real notification was posted. pymacos called it with the message Monitor disk "backup" café 🚀 on <host> failed and the title SimpleMonitor, unchanged.

Comment thread tests/test_nc.py Fixed

This branch has not been deployed

No deployments
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