Added Send mail functionality & Dockerized application #1

Merged
PeterSurda merged 11 commits from cis-kuldeep/influx-smtp-gateway:master into master 2022-02-21 07:41:14 +01:00
Showing only changes of commit 5881dc7b1a - Show all commits

25
main.py
View File

@ -3,11 +3,9 @@
Serve cloud init files
"""
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
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
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()
except Exception: # pylint: disable=broad-except