Added Send mail functionality & Dockerized application #1
25
main.py
25
main.py
|
@ -3,11 +3,9 @@
|
||||||
Serve cloud init files
|
Serve cloud init files
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import configparser
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import smtplib
|
import smtplib
|
||||||
import socket
|
|
||||||
import sys
|
import sys
|
||||||
from email.header import Header
|
from email.header import Header
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
@ -61,31 +59,16 @@ if __name__ == "__main__":
|
||||||
TO_MAIL = os.environ["to_mail"]
|
TO_MAIL = os.environ["to_mail"]
|
||||||
FROM_MAIL = os.environ["from_mail"]
|
FROM_MAIL = os.environ["from_mail"]
|
||||||
FROM_MAIL_PASSWORD = os.environ["from_mail_password"]
|
FROM_MAIL_PASSWORD = os.environ["from_mail_password"]
|
||||||
except:
|
except: # noqa:E722
|
||||||
raise "Please check missing environment variables: to_mail, from_mail, from_mail_password"
|
raise "Please check missing environment variables: to_mail, from_mail, \
|
||||||
|
from_mail_password"
|
||||||
|
|
||||||
cherrypy.server.socket_host = SERVER_HOST
|
cherrypy.server.socket_host = SERVER_HOST
|
||||||
cherrypy.server.socket_port = SERVER_PORT
|
cherrypy.server.socket_port = SERVER_PORT
|
||||||
ENGINE = cherrypy.engine
|
ENGINE = cherrypy.engine
|
||||||
|
|
||||||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
cherrypy.tree.mount(ROOT, config={})
|
||||||
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)
|
|
||||||
|
|
||||||
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