Commit a8372920 by ajil.k

added

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (task3)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/task3.iml" filepath="$PROJECT_DIR$/.idea/task3.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
from scripts.services.mailing import send_mails
# Sender Password : qdxdqahjeqbneaci
# sender_password = input("Enter the Password to send the mail: ")
sender_password = "qdxdqahjeqbneaci"
mail_status = send_mails(sender_password)
if mail_status:
print("Mail sent")
else:
print("Mail not sent")
class MailSentException(Exception):
pass
class NoDataErrorException(Exception):
pass
import pandas as pd
from scripts.core.handlers.exceptions import NoDataErrorException
data_xlsx = pd.read_excel("scripts/utils/task3.xlsx")
def average_data():
try:
average_columns = [data_xlsx['kWh'].mean(),
data_xlsx['kVAh'].mean(),
data_xlsx['kW'].mean(),
data_xlsx['kVA'].mean(),
data_xlsx['current'].mean()]
return average_columns
except NoDataErrorException:
print("NoDataErrorException Occurred")
def max_data():
try:
max_columns = [data_xlsx['kWh'].max(),
data_xlsx[data_xlsx['kWh'] == data_xlsx['kWh'].max()]['Timestamp'],
data_xlsx['kVAh'].max(),
data_xlsx[data_xlsx['kVAh'] == data_xlsx['kVAh'].max()]['Timestamp'],
data_xlsx['kW'].max(),
data_xlsx[data_xlsx['kW'] == data_xlsx['kW'].max()]['Timestamp'],
data_xlsx['kVA'].max(),
data_xlsx[data_xlsx['kVA'] == data_xlsx['kVA'].max()]['Timestamp'],
data_xlsx['current'].max(),
data_xlsx[data_xlsx['current'] == data_xlsx['current'].max()]['Timestamp']]
return max_columns
except NoDataErrorException:
print("NoDataErrorException Occurred")
def min_data():
try:
min_columns = [data_xlsx['kWh'].min(),
data_xlsx[data_xlsx['kWh'] == data_xlsx['kWh'].min()]['Timestamp'],
data_xlsx['kVAh'].min(),
data_xlsx[data_xlsx['kVAh'] == data_xlsx['kVAh'].min()]['Timestamp'],
data_xlsx['kW'].min(),
data_xlsx[data_xlsx['kW'] == data_xlsx['kW'].min()]['Timestamp'],
data_xlsx['kVA'].min(),
data_xlsx[data_xlsx['kVA'] == data_xlsx['kVA'].min()]['Timestamp'],
data_xlsx['current'].min(),
data_xlsx[data_xlsx['current'] == data_xlsx['current'].min()]['Timestamp']]
return min_columns
except NoDataErrorException:
print("NoDataErrorException Occurred")
import smtplib
from email.message import EmailMessage
from scripts.core.handlers.exceptions import MailSentException
from scripts.core.handlers.mailing_content import average_data, min_data, max_data
from scripts.constants.port_number import port_no
def send_mails(sender_password):
try:
sender_email_id = "ajil.intern.knowledgelens@gmail.com"
receiver_email_ids = ["ajilkunjumon2000@gmail.com",
"2150@tkmce.ac.in", ""]
message = EmailMessage()
message['Subject'] = "Email with xlsx Attachment"
message['From'] = sender_email_id
message['To'] = receiver_email_ids
file_path_name = "scripts/utils/task3.xlsx"
average_list = average_data()
min_list = min_data()
max_list = max_data()
# for i in average_list:
body = f"Average of List: {average_list}" \
f"\nMin of List: {min_list}" \
f"\nMax of List: {max_list}"
body = body.replace("Name: Timestamp, dtype: datetime64[ns]", " ")
body = body.replace("[", "\n")
body = body.replace("]", "\n")
message.set_content(body)
with open(file_path_name, "rb") as f:
file_data = f.read()
file_name = f.name
message.add_attachment(file_data, maintype='application',
subtype='xlsx', filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com', port_no) as server:
server = smtplib.SMTP_SSL('smtp.gmail.com', port_no)
server.login(sender_email_id, sender_password)
server.send_message(message)
return True
except MailSentException:
print("Exception Occurred")
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