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
|
||||||
|
|
||||||
PeterSurda marked this conversation as resolved
Outdated
|
|||||||
logging.basicConfig(filename='app.log', filemode='w',
|
logging.basicConfig(stream=sys.stdout,
|
||||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
should log to stdout or stderr (research which one is more appropriate) should log to stdout or stderr (research which one is more appropriate)
|
|||||||
format='%(name)s - %(levelname)s - %(message)s')
|
format='%(name)s - %(levelname)s - %(message)s')
|
||||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
docstring docstring
|
|||||||
|
|
||||||
|
|
||||||
PeterSurda marked this conversation as resolved
PeterSurda
commented
this should go under this should go under `__main__`
|
|||||||
|
@ -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:
|
||||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
`except (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__":
|
||||||
|
|
||||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
live data shouldn't be here, squash to get rid of it live data shouldn't be here, squash to get rid of it
|
|||||||
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
class name