Added Send mail functionality & Dockerized application #1
8
main.py
8
main.py
|
@ -14,7 +14,7 @@ from email.mime.text import MIMEText
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logging.basicConfig(filename='app.log', filemode='w',
|
logging.basicConfig(stream=sys.stdout,
|
||||||
format='%(name)s - %(levelname)s - %(message)s')
|
format='%(name)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
|
|
||||||
PeterSurda marked this conversation as resolved
|
|||||||
|
@ -49,7 +49,7 @@ class SMTPWebhookApp:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = smtplib.SMTP(host=SMTP_SERVER_HOST, port=SMTP_SERVER_PORT)
|
client = smtplib.SMTP(host=SMTP_SERVER_HOST, port=SMTP_SERVER_PORT)
|
||||||
except Exception as e:
|
except (smtplib.SMTPConnectionError, TimeoutError) as e:
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
logging.error("To: {}, error: {}".format(TO_MAIL, e))
|
logging.error("To: {}, error: {}".format(TO_MAIL, e))
|
||||||
return {"status": 400, "message": "SMTP client error: {}.".format(
|
return {"status": 400, "message": "SMTP client error: {}.".format(
|
||||||
|
@ -109,6 +109,10 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
cherrypy.tree.mount(ROOT, config={})
|
cherrypy.tree.mount(ROOT, config={})
|
||||||
|
|
||||||
|
if hasattr(ENGINE, "signal_handler"):
|
||||||
|
ENGINE.signal_handler.subscribe()
|
||||||
|
if hasattr(ENGINE, "console_control_handler"):
|
||||||
|
ENGINE.console_control_handler.subscribe()
|
||||||
try:
|
try:
|
||||||
ENGINE.start()
|
ENGINE.start()
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
this should go under
__main__