Added Send mail functionality & Dockerized application #1
25
main.py
25
main.py
|
@ -3,11 +3,9 @@
|
|||
Serve cloud init files
|
||||
PeterSurda marked this conversation as resolved
Outdated
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import os
|
||||
import json
|
||||
import smtplib
|
||||
import socket
|
||||
import sys
|
||||
from email.header import Header
|
||||
from email.mime.text import MIMEText
|
||||
|
@ -61,31 +59,16 @@ if __name__ == "__main__":
|
|||
TO_MAIL = os.environ["to_mail"]
|
||||
FROM_MAIL = os.environ["from_mail"]
|
||||
FROM_MAIL_PASSWORD = os.environ["from_mail_password"]
|
||||
except:
|
||||
raise "Please check missing environment variables: to_mail, from_mail, from_mail_password"
|
||||
except: # noqa:E722
|
||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
`except KeyError`
|
||||
raise "Please check missing environment variables: to_mail, from_mail, \
|
||||
from_mail_password"
|
||||
|
||||
cherrypy.server.socket_host = SERVER_HOST
|
||||
cherrypy.server.socket_port = SERVER_PORT
|
||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
`except smtplib.SMTPException`
|
||||
ENGINE = cherrypy.engine
|
||||
|
||||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
CONFIG = {
|
||||
'/include': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(CURRENT_DIR,
|
||||
'data',
|
||||
'include'),
|
||||
'tools.staticdir.content_types': {
|
||||
'yml': 'text/yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
cherrypy.tree.mount(ROOT, config=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:
|
||||
ENGINE.start()
|
||||
PeterSurda marked this conversation as resolved
Outdated
PeterSurda
commented
merge with previous merge with previous `try`/`except`
|
||||
except Exception: # pylint: disable=broad-except
|
||||
|
|
Loading…
Reference in New Issue
Block a user
change docstring