restic-compose-backup/restic_compose_backup/alerts/__init__.py

27 lines
741 B
Python
Raw Normal View History

2019-12-04 19:28:06 +00:00
import logging
from restic_compose_backup.alerts.smtp import SMTPAlert
from restic_compose_backup.alerts.discord import DiscordWebhookAlert
from restic_compose_backup.config import Config
2019-12-04 19:28:06 +00:00
logger = logging.getLogger(__name__)
2019-12-04 02:58:27 +00:00
ALERT_INFO = 'INFO',
ALERT_ERROR = 'ERROR'
ALERT_TYPES = [ALERT_INFO, ALERT_ERROR]
BACKENDS = [SMTPAlert, DiscordWebhookAlert]
2019-12-04 02:58:27 +00:00
def configured_alert_classes():
"""Returns a list of configured alert class instances"""
2019-12-04 19:28:06 +00:00
logger.debug('Getting alert backends')
entires = []
for cls in BACKENDS:
instance = cls.create_from_env()
2019-12-04 19:28:06 +00:00
logger.debug("Alert backend '%s' configured: %s", cls.name, instance != None)
if instance:
entires.append(instance)
return entires