Made SMTP logging optional and added notification creation log
This commit is contained in:
parent
7365949fb5
commit
81bbad018b
@ -83,6 +83,8 @@ def create_app(test_config=None, instance_path=None):
|
|||||||
if app.config.get("SECRET_KEY"):
|
if app.config.get("SECRET_KEY"):
|
||||||
os.environ["SECRET_KEY"] = app.config["SECRET_KEY"]
|
os.environ["SECRET_KEY"] = app.config["SECRET_KEY"]
|
||||||
|
|
||||||
|
defs.SMTP_DEBUG_LEVEL = app.config.get("SMTP_DEBUG_LEVEL", defs.SMTP_DEBUG_LEVEL)
|
||||||
|
|
||||||
local_db.initPool(os.path.dirname(app.instance_path), config=app.config)
|
local_db.initPool(os.path.dirname(app.instance_path), config=app.config)
|
||||||
logging.info('App started')
|
logging.info('App started')
|
||||||
|
|
||||||
|
|||||||
@ -18,3 +18,6 @@ shipcall_types = {
|
|||||||
3: "Shifting"
|
3: "Shifting"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Email transport logging (0 = quiet, 1 = verbose)
|
||||||
|
SMTP_DEBUG_LEVEL = 0
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,11 @@ def SendEmails(email_dict):
|
|||||||
conn = smtplib.SMTP_SSL(defs.email_credentials["server"], defs.email_credentials["port"])
|
conn = smtplib.SMTP_SSL(defs.email_credentials["server"], defs.email_credentials["port"])
|
||||||
else:
|
else:
|
||||||
conn = smtplib.SMTP(defs.email_credentials["server"], defs.email_credentials["port"])
|
conn = smtplib.SMTP(defs.email_credentials["server"], defs.email_credentials["port"])
|
||||||
conn.set_debuglevel(1) # set this to 0 to disable debug output to log
|
try:
|
||||||
|
smtp_debug_level = int(defs.SMTP_DEBUG_LEVEL)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
smtp_debug_level = 0
|
||||||
|
conn.set_debuglevel(1 if smtp_debug_level else 0)
|
||||||
conn.ehlo()
|
conn.ehlo()
|
||||||
if encryption_norm in ("STARTTLS", "STARTSSL"):
|
if encryption_norm in ("STARTTLS", "STARTSSL"):
|
||||||
conn.starttls()
|
conn.starttls()
|
||||||
@ -306,6 +310,13 @@ def SendNotifications():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# mark as sent
|
# mark as sent
|
||||||
|
logging.info(
|
||||||
|
"Notification finalized (level=2): id=%s shipcall_id=%s participant_id=%s type=%s",
|
||||||
|
notification.id,
|
||||||
|
notification.shipcall_id,
|
||||||
|
notification.participant_id,
|
||||||
|
notification.type,
|
||||||
|
)
|
||||||
commands.execute("UPDATE notification SET level = 2 WHERE id = ?id?", param={"id":notification.id})
|
commands.execute("UPDATE notification SET level = 2 WHERE id = ?id?", param={"id":notification.id})
|
||||||
|
|
||||||
# send emails (if any)
|
# send emails (if any)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user