fix typo in setup.py

handle if apprise cannot be imported
This commit is contained in:
Pim Kunis 2023-09-25 10:17:56 +02:00 committed by pizzapim
parent 5a989826a1
commit db8079b699
2 changed files with 15 additions and 11 deletions

View File

@ -1,17 +1,7 @@
import logging
import apprise
from apprise import NotifyType, NotifyFormat
logger = logging.getLogger(__name__)
state_to_notify_type = {
'start': NotifyType.INFO,
'finish': NotifyType.SUCCESS,
'fail': NotifyType.FAILURE,
'log': NotifyType.INFO
}
def initialize_monitor(
ping_url, config, config_filename, monitoring_log_level, dry_run
@ -27,6 +17,20 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
Ping the configured Apprise service URLs. Use the given configuration filename in any log
entries. If this is a dry run, then don't actually ping anything.
'''
try:
import apprise
from apprise import NotifyType, NotifyFormat
except ImportError:
logger.warning('Unable to import Apprise in monitoring hook')
return
state_to_notify_type = {
'start': NotifyType.INFO,
'finish': NotifyType.SUCCESS,
'fail': NotifyType.FAILURE,
'log': NotifyType.INFO
}
run_states = hook_config.get('states', ['fail'])
if state.name.lower() not in run_states:

View File

@ -36,7 +36,7 @@ setup(
'ruamel.yaml>0.15.0,<0.18.0',
'setuptools'
),
extra_require={
extras_require={
"Apprise": ["apprise"]
},
include_package_data=True,