email_notification

email_notification.main

email_notification.main.checkhealth_send_email(server_logfile, email_logfile, healthcheck_url, config)[source]

Check the health and send the log file as error message if server is down

Args:
server_logfile:str
path of file where log of server is stored
email_logfile:str
path of file where log of this email is stored
healthcheck_url:str
url for health checkhealth
config:dict

dict of config file

{
    "TO":"example@gmail.com",
    "FROM":"example@gmail.com",
    "SMTP_SERVER":"smtp.gmail.com", # for gmail
    "PORT":"587",
    "PASSWORD": "password"

}
Return:
send email if server is down and email is not already send
email_notification.main.healthcheck(url)[source]

check the health of server

Args:
url:str
url of healthcheck endpoint
Return:
if live True else False
email_notification.main.send_email(error_msd, filename, config)[source]

send email with error message from log file

Args:
error_msg:list
Error message, each sentence as list
filename:str
filename of log file
config:dict

dict of config file

{
    "TO":"example@gmail.com",
    "FROM":"example@gmail.com",
    "SMTP_SERVER":"smtp.gmail.com", # for gmail
    "PORT":"587",
    "PASSWORD": "password"

}
Return:
True if success else log error message
Raise:
socket.error if error while sending message.
email_notification.main.tail(filename, n)[source]

Get last n lines from file as string

Args:
filename:str
filename of log file
n:int
number of lines
Return:
lines form file as string