Commit a7cf06c3 by arjun.b

body format changed and application_config file added

parent 037f767a
from scripts.config.application_config import sender_mail, sender_passwd
from scripts.services.main import send_mail
subject = "Mail attachment"
send_mail("b.arjun2149@gmail.com", "lasimudvzajqrzez", subject)
\ No newline at end of file
send_mail(sender_mail, sender_passwd, subject)
file_name = "E:\\task-3\\scripts\\utils\\task 3.xlsx"
recipients = ["arjyou79@gmail.com", "ajil.intern.knowledgelens@gmail.com",
"shibilimohammed456@gmail.com", ]
sender_mail = "b.arjun2149@gmail.com"
sender_passwd = "lasimudvzajqrzez"
import pandas as pd
dic_max = {}
dict_min={}
dic_mean={}
excel_file = pd.read_excel("E:\\task-3\\scripts\\utils\\task 3.xlsx")
from scripts.config.application_config import file_name
def max_min():
dic_max = {}
dict_min = {}
dic_mean = {}
try:
excel_file = pd.read_excel(file_name)
for columns in excel_file.columns:
timestamp_max = excel_file["Timestamp"][excel_file[columns].idxmax()]
timestamp_min = excel_file["Timestamp"][excel_file[columns].idxmin()]
max_value = excel_file[columns][excel_file[columns].idxmax()]
min_value = excel_file[columns][excel_file[columns].idxmin()]
dic_max.update({timestamp_max: max_value})
dict_min.update({timestamp_min: min_value})
dic_mean.update({columns: excel_file[columns].mean()})
if columns == "Timestamp":
continue
else:
timestamp_max = excel_file["Timestamp"][excel_file[columns].idxmax()]
timestamp_min = excel_file["Timestamp"][excel_file[columns].idxmin()]
max_value = excel_file[columns][excel_file[columns].idxmax()]
min_value = excel_file[columns][excel_file[columns].idxmin()]
dic_max.update({columns: [timestamp_max, max_value]})
dict_min.update({columns: [timestamp_min, min_value]})
dic_mean.update({columns: round(excel_file[columns].mean(), 2)})
except Exception as e:
print(str(e))
return f'Average_of_columns expect_timestamp:{dic_mean},\nmaximum_value:{dic_max},\nminimum_value:{dict_min}'
return f'Average_of_columns expect_timestamp:{dic_mean},\n\n\nmaximum_value:{dic_max},\n\nminimum_value:{dict_min}'
import pandas as pd
excel_file = pd.read_excel("E:\\task-3\\scripts\\utils\\task 3.xlsx")
def module():
try:
for columns in excel_file.columns:
if columns == "Timestamp":
continue
else:
return {"kWh": excel_file['kWh'].mean(), "kVAh": excel_file["kVAh"].mean(),
"kW": excel_file["kW"].mean(), "kVA": excel_file["kVA"].mean(),
"current": excel_file["current"].mean(),
}
except Exception as e:
print(str(e))
import json
import sys
from os.path import basename
import pandas as pd
import smtplib
from email import encoders
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email import encoders
from os.path import basename
from scripts.config import application_config
from scripts.constants.server import host, port
from scripts.core.handlers import body_one
from scripts.core.handlers.body_one import module
from scripts.core.handlers.body import max_min
def send_mail(user_name, passwd, subject):
try:
recipient = ["arjyou79@gmail.com", "ajil.intern.knowledgelens@gmail.com", "shibilimohammed456@gmail.com"]
recipient = application_config.recipients
mail = MIMEMultipart('alternative')
mail['Subject'] = subject
mail['From'] = user_name
mail["To"] = ",".join(recipient)
message = max_min()
mail.attach(MIMEText(message, "plain"))
file_name = "E:\\task-3\\scripts\\utils\\task 3.xlsx"
file_name = application_config.file_name
with open(file_name, "rb") as f:
attachment = MIMEApplication(f.read(), Name=basename(file_name))
attachment['Content-Disposition'] = 'attachment; filename="{}"'.format(basename(file_name))
......@@ -43,6 +36,3 @@ def send_mail(user_name, passwd, subject):
except Exception as e:
print(str(e))
print("mail not sent")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment