added code to initialize db with models and recodres

This commit is contained in:
Tobias Kurze
2019-11-20 12:41:05 +01:00
parent bc1347fe99
commit 60ff5bdeaf
20 changed files with 1658 additions and 136 deletions

View File

@@ -1,9 +1,10 @@
import smtplib
import traceback
from email.message import EmailMessage
from logging.handlers import SMTPHandler
from typing import List, Union
from backend import main_logger, Config
from backend import Config
def send_mail(subject: str, msg_body: str, to_mail: List, from_mail: str = Config.FROM_MAIL):
@@ -18,7 +19,7 @@ def send_mail(subject: str, msg_body: str, to_mail: List, from_mail: str = Confi
s.send_message(msg)
s.quit()
except Exception as e:
main_logger.error(
print(
"Could not send E-Mail (Exception: {})".format(str(e)))
@@ -43,3 +44,17 @@ def send_error_mail(message_or_exception: Union[str, Exception], subject: str =
def send_warning_mail():
pass
def get_smtp_default_handler(receiver_mail_addresses=Config.ADMIN_E_MAIL_TO, subject: str = None,
subject_prefix: str = "[LRC] Log: "):
subject = subject if subject.startswith("[LRC]") else subject_prefix + subject
return SMTPHandler(Config.SMTP_SERVER, Config.FROM_MAIL, receiver_mail_addresses, subject)
def get_smtp_error_handler(receiver_mail_addresses=Config.ERROR_E_MAIL_TO, subject: str = None,
subject_prefix: str = "[LRC] Error: "):
subject = subject if subject.startswith("[LRC]") else subject_prefix + subject
return SMTPHandler(Config.SMTP_SERVER, Config.FROM_MAIL, receiver_mail_addresses, subject)