Skip to content

Added Rain Alert Mail Sender#997

Merged
kaustubhgupta merged 9 commits into
avinashkranjan:masterfrom
Shubhrima:issue-993
May 27, 2021
Merged

Added Rain Alert Mail Sender#997
kaustubhgupta merged 9 commits into
avinashkranjan:masterfrom
Shubhrima:issue-993

Conversation

@Shubhrima

@Shubhrima Shubhrima commented Apr 30, 2021

Copy link
Copy Markdown
Contributor

Description

An application that checks the weather condition for the next 12 hours and sends a message to the registered mail address number as to whether one should carry a sunglass (if it is sunny) , or an umbrella (if it rains).

Fixes #993

Have you read the Contributing Guidelines on Pull Requests?

  • Yes
  • No

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [ x] My code follows the style guidelines(Clean Code) of this project
  • [x ] I have performed a self-review of my own code
  • [x ] I have commented my code, particularly in hard-to-understand areas
  • [ x] I have created a helpful and easy to understand README.md
  • [ x] My documentation follows Template for README.md
  • [x ] My changes generate no new warnings
  • [x ] I have added tests/screenshots(if any) that prove my fix is effective or that my feature works.
  • [x ] I have added the project meta data in the PR template.
  • [x ] I have created the requirements.txt file if needed

Project Metadata

If there is no-file/nothing to fill the below fields with, then type: none

Example: If no requirements.txt needed/present, then type none in Requirments.

Category:

  • Calculators
  • AI/ML
  • Scrappers
  • Social_Media
  • PDF
  • Image_Processing
  • Video_Processing
  • Games
  • Networking
  • OS_Utilities
  • Automation
  • Cryptography
  • Computer_Vision
  • Fun
  • Others

Title: Rain Alert Mail Sender

Folder: Rain Alert Mail Sender

Requirements: requirements.txt

Script: main.py

Arguments: none

Contributor: Shubhrima

Description: An application that alerts about the weather for the next 12 hours.

Comment thread Rain Alert Mail Sender/main.py Outdated
Comment on lines +5 to +7
MY_MAIL= ENTER_YOUR_MAIL
MY_PASSWORD= ENTER_YOUR_PASSWORD
RECIEVER_MAIL = RECIEVER_MAIL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get these inputs from user using input function

Comment thread Rain Alert Mail Sender/main.py Outdated
Comment on lines +9 to +10
LAT = 22.572645
LONG = 88.363892

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these coordinates for? If you're using them for location then get the location from the user and then use https://nominatim.openstreetmap.org/search/ to get the exact coordinates of the location

Comment thread Rain Alert Mail Sender/main.py Outdated
LAT = 22.572645
LONG = 88.363892

API_KEY = API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get it from user

Comment thread Rain Alert Mail Sender/main.py Outdated
@kaustubhgupta kaustubhgupta added bug Something isn't working enhancement New feature or request labels May 1, 2021
@Shubhrima

Copy link
Copy Markdown
Contributor Author

@kaustubhgupta please check

Comment thread Rain Alert Mail Sender/main.py Outdated
RECIEVER_MAIL = input('Send mail to (mail id): ')
CITY = input('Enter your City: ')

API_KEY = input('Type in API from OpenWeather: ')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
API_KEY = input('Type in API from OpenWeather: ')
API_KEY = input('Type in API key from OpenWeather: ')

Comment thread Rain Alert Mail Sender/main.py Outdated
Comment on lines +39 to +52
if (bring_umbrella == True):
with SMTP("smtp.gmail.com") as connection:
connection.starttls()
connection.login(user=MY_MAIL, password=MY_PASSWORD)
connection.sendmail(from_addr=MY_MAIL, to_addrs=RECIEVER_MAIL,
msg=f"Subject: Rain Rain \n\nIt's going to rain today. Bring Umbrella ")
print('Mail Sent')
else:
with SMTP("smtp.gmail.com") as connection:
connection.starttls()
connection.login(user=MY_MAIL, password=MY_PASSWORD)
connection.sendmail(from_addr=MY_MAIL, to_addrs='shubhrijana@gmail.com',
msg=f"Subject: Sunny Day\n\nMay be a sunny day. Carry sunglasses. ")
print('Mail Sent')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of duplicating the code for making a Gmail connection, the only thing that changes in if-else is the msg content. So, in if-else statements, just modify the message variable and then sent the message. This is what I mean to say:

if umbrella:
  msg = Subject: Rain Rain \n\nIt's going to rain today. Bring Umbrella
else:
  msg = Subject: Sunny Day\n\nMay be a sunny day. Carry sunglasses.

with SMTP("smtp.gmail.com") as connection:
  connection.sendmail(from_addr=MY_MAIL, to_addrs=RECIEVER_MAIL, msg=msg)

@Shubhrima

Copy link
Copy Markdown
Contributor Author

@kaustubhgupta please check

Comment thread Rain Alert Mail Sender/main.py Outdated
MY_MAIL= input('Enter your mail id: ')
MY_PASSWORD= input('Enter password: ')
RECIEVER_MAIL = input('Send mail to (mail id): ')
#get latitude longitude from "https://www.latlong.net/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this comment

Comment thread Rain Alert Mail Sender/main.py Outdated
import requests
from smtplib import SMTP

#turn off certain security criteria in sender mail address

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What type of security criteria? Kindly mention them as doc string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaustubhgupta kaustubhgupta added next review needed Approved by some mentors, more approvals needed and removed bug Something isn't working enhancement New feature or request labels May 4, 2021

@Kushal997-das Kushal997-das left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@antrikshmisri antrikshmisri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking inputs for every variable, you can take the values from a .env file.

@Shubhrima

Copy link
Copy Markdown
Contributor Author

Instead of taking inputs for every variable, you can take the values from a .env file.

Please Check

@santushtisharma10 santushtisharma10 added Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level2 Bug fixing, Adding small features and removed next review needed Approved by some mentors, more approvals needed labels May 5, 2021

@kaustubhgupta kaustubhgupta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shubhrima Add the requirements.txt file and update the PR template with project metadata. Look at this PR for reference: #1002

@kaustubhgupta kaustubhgupta added hold Needs a second thought and removed Approved PR Approved and Ready to Merge labels May 11, 2021
@Shubhrima

Copy link
Copy Markdown
Contributor Author

@Shubhrima Add the requirements.txt file and update the PR template with project metadata. Look at this PR for reference: #1002

please check

@kaustubhgupta kaustubhgupta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR template is wrongly filled. Please check other approved PRs for better understanding

@Shubhrima

Copy link
Copy Markdown
Contributor Author

PR template is wrongly filled. Please check other approved PRs for better understanding

Is it okay now?

@kaustubhgupta kaustubhgupta added Approved PR Approved and Ready to Merge and removed hold Needs a second thought labels May 15, 2021
@github-actions

Copy link
Copy Markdown

Due to inactivity this pull request has been marked as stale.

@github-actions github-actions Bot added the Stale PRs with no updates label May 23, 2021
@kaustubhgupta kaustubhgupta added manual-db-update-req The PR was merged but db was not updated. Need to update the database manully and removed Stale PRs with no updates labels May 23, 2021
@kaustubhgupta kaustubhgupta merged commit 44a71e7 into avinashkranjan:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level2 Bug fixing, Adding small features manual-db-update-req The PR was merged but db was not updated. Need to update the database manully

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rain Alert Mail Sender

5 participants