Skip to content
Snippets Groups Projects
Commit 0f7898ad authored by David Trattnig's avatar David Trattnig
Browse files

Ability to disable sending of mails. #38

parent ccf246e0
No related branches found
No related tags found
No related merge requests found
...@@ -18,16 +18,19 @@ db_charset="utf8" ...@@ -18,16 +18,19 @@ db_charset="utf8"
[monitoring] [monitoring]
mail_server="mail.example.com" mail_server="mail.your-radio.org"
mail_server_port="587" mail_server_port="587"
mail_user="aura@subsquare.at" mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---" mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at" # Set to "true" if you want to notify admins about incidents, otherwise "false"
# Which from mailadress should be used mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine" from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client # A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[Aura Engine]" mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to # Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1" heartbeat_server = "127.0.0.1"
# Some UDP port # Some UDP port
...@@ -36,9 +39,10 @@ heartbeat_port = 43334 ...@@ -36,9 +39,10 @@ heartbeat_port = 43334
heartbeat_frequency = 1 heartbeat_frequency = 1
logdir="/home/username/code/aura/engine/logs" logdir="/home/username/code/aura/engine/logs"
# possible values: debug, info, warning, error, critical # Possible values: debug, info, warning, error, critical
loglevel="info" loglevel="info"
[api] [api]
## STEERING ## ## STEERING ##
......
...@@ -18,27 +18,31 @@ db_charset="utf8" ...@@ -18,27 +18,31 @@ db_charset="utf8"
[monitoring] [monitoring]
mail_server="mail.example.com" mail_server="mail.your-radio.org"
mail_server_port="587" mail_server_port="587"
mail_user="aura@subsquare.at" mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---" mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at" # Set to "true" if you want to notify admins about incidents, otherwise "false"
# Which from mailadress should be used mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine" from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client # A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[Aura Engine]" mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to # Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1" heartbeat_server = "127.0.0.1"
# Some UDP port # Some UDP port
heartbeat_port = 43334 heartbeat_port = 43334
# Seconds how often the vitality of the Engine should be checked (0 = disabled) # Seconds how often the vitality of the Engine should be checked (0 = disabled)
heartbeat_frequency = 1 heartbeat_frequency = 1
logdir="/srv/logs" logdir="/home/username/code/aura/engine/logs"
# Possible values: debug, info, warning, error, critical # Possible values: debug, info, warning, error, critical
loglevel="info" loglevel="info"
[api] [api]
## STEERING ## ## STEERING ##
......
...@@ -18,27 +18,31 @@ db_charset="utf8" ...@@ -18,27 +18,31 @@ db_charset="utf8"
[monitoring] [monitoring]
mail_server="mail.example.com" mail_server="mail.your-radio.org"
mail_server_port="587" mail_server_port="587"
mail_user="aura@subsquare.at" mail_user="aura@subsquare.at"
mail_pass="---SECRET--PASSWORD---" mail_pass="---SECRET--PASSWORD---"
# If you want to send multiple adminmails, make them space separated
admin_mail="david@subsquare.at" # Set to "true" if you want to notify admins about incidents, otherwise "false"
# Which from mailadress should be used mail_admin_enabled="true"
# If you want to send multiple admin-mails, make them space separated
admin_mail="admin@your-radio.org"
# The FROM email address used when sending
from_mail="monitoring@aura.engine" from_mail="monitoring@aura.engine"
# The beginning of the subject. With that you can easily apply filter rules using a mail client # A subject prefix allows applying filter rules in your mail client
mailsubject_prefix="[Aura Engine]" mailsubject_prefix="[AURA Engine]"
# Server where heartbeat info is sent to # Server where heartbeat info is sent to
heartbeat_server = "127.0.0.1" heartbeat_server = "127.0.0.1"
# Some UDP port # Some UDP port
heartbeat_port = 43334 heartbeat_port = 43334
# Seconds how often the vitality of the Engine should be checked (0 = disabled) # Seconds how often the vitality of the Engine should be checked (0 = disabled)
heartbeat_frequency = 1 heartbeat_frequency = 1
logdir="/var/log/aura" logdir="/home/username/code/aura/engine/logs"
# *ossible values: debug, info, warning, error, critical # Possible values: debug, info, warning, error, critical
loglevel="info" loglevel="info"
[api] [api]
## STEERING ## ## STEERING ##
......
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import smtplib import smtplib
from email.message import EmailMessage from email.message import EmailMessage
from src.base.config import AuraConfig from src.base.config import AuraConfig
from src.base.utils import SimpleUtil as SU
class MailingException(Exception): class MailingException(Exception):
...@@ -35,8 +38,6 @@ class MailingException(Exception): ...@@ -35,8 +38,6 @@ class MailingException(Exception):
class AuraMailer(): class AuraMailer():
""" """
Event handler to send emails to Aura administrators and programme coordinators. Event handler to send emails to Aura administrators and programme coordinators.
""" """
engine = None engine = None
mail = None mail = None
...@@ -92,7 +93,9 @@ class MailService(): ...@@ -92,7 +93,9 @@ class MailService():
Service to send emails to Aura administrators. Service to send emails to Aura administrators.
""" """
config = None config = None
logger = None
admin_mails = None admin_mails = None
admin_mails_enabled = None
def __init__(self): def __init__(self):
...@@ -100,7 +103,9 @@ class MailService(): ...@@ -100,7 +103,9 @@ class MailService():
Constructor Constructor
""" """
self.config = AuraConfig.config() self.config = AuraConfig.config()
self.logger = logging.getLogger("AuraEngine")
self.admin_mails = self.config.get("admin_mail") self.admin_mails = self.config.get("admin_mail")
self.admin_mails_enabled = self.config.get("mail_admin_enabled")
# #
...@@ -116,6 +121,10 @@ class MailService(): ...@@ -116,6 +121,10 @@ class MailService():
subject (String): The email subject subject (String): The email subject
body (String): The email body text body (String): The email body text
""" """
if self.admin_mails_enabled == "false":
self.logger.warning(SU.red("No admin mail sent, because doing so is disabled in engine.ini!"))
return False
admin_mails = self.admin_mails.split() admin_mails = self.admin_mails.split()
for mail_to in admin_mails: for mail_to in admin_mails:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment