/opt/homebrew/bin/terminal-notify path added to MacOSX (#509)

This commit is contained in:
Chris Caron 2021-12-28 13:21:39 -05:00 committed by GitHub
parent 9242445126
commit 12326c755b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -91,8 +91,11 @@ class NotifyMacOSX(NotifyBase):
# content to display
body_max_line_count = 10
# The path to the terminal-notifier
notify_path = '/usr/local/bin/terminal-notifier'
# The possible paths to the terminal-notifier
notify_paths = (
'/opt/homebrew/bin/terminal-notify',
'/usr/local/bin/terminal-notifier',
)
# Define object templates
templates = (
@ -127,6 +130,10 @@ class NotifyMacOSX(NotifyBase):
# or not.
self.include_image = include_image
# Acquire the notify path
self.notify_path = next( # pragma: no branch
(p for p in self.notify_paths if os.access(p, os.X_OK)), None)
# Set sound object (no q/a for now)
self.sound = sound
return
@ -136,10 +143,11 @@ class NotifyMacOSX(NotifyBase):
Perform MacOSX Notification
"""
if not os.access(self.notify_path, os.X_OK):
if not (self.notify_path and os.access(self.notify_path, os.X_OK)):
self.logger.warning(
"MacOSX Notifications require '{}' to be in place."
.format(self.notify_path))
"MacOSX Notifications requires one of the following to "
"be in place: '{}'.".format(
'\', \''.join(self.notify_paths)))
return False
# Start with our notification path

View File

@ -77,7 +77,7 @@ def test_plugin_macosx_general(mock_macver, mock_system, mock_popen, tmpdir):
reload(sys.modules['apprise'])
# Point our object to our new temporary existing file
apprise.plugins.NotifyMacOSX.notify_path = str(script)
apprise.plugins.NotifyMacOSX.notify_paths = (str(script), )
obj = apprise.Apprise.instantiate(
'macosx://_/?image=True', suppress_exceptions=False)
@ -150,7 +150,7 @@ def test_plugin_macosx_general(mock_macver, mock_system, mock_popen, tmpdir):
reload(sys.modules['apprise'])
# Point our object to our new temporary existing file
apprise.plugins.NotifyMacOSX.notify_path = str(script)
apprise.plugins.NotifyMacOSX.notify_paths = (str(script), )
# Our object is disabled
obj = apprise.Apprise.instantiate(
@ -168,7 +168,7 @@ def test_plugin_macosx_general(mock_macver, mock_system, mock_popen, tmpdir):
reload(sys.modules['apprise'])
# Point our object to our new temporary existing file
apprise.plugins.NotifyMacOSX.notify_path = str(script)
apprise.plugins.NotifyMacOSX.notify_paths = (str(script), )
obj = apprise.Apprise.instantiate(
'macosx://_/?sound=default', suppress_exceptions=False)
@ -182,7 +182,7 @@ def test_plugin_macosx_general(mock_macver, mock_system, mock_popen, tmpdir):
reload(sys.modules['apprise'])
# Point our object to our new temporary existing file
apprise.plugins.NotifyMacOSX.notify_path = str(script)
apprise.plugins.NotifyMacOSX.notify_paths = (str(script), )
# This is just to test that the the minor (in this case .12)
# is only weighed with respect to the major number as wel