Skip to content

Commit 83776f2

Browse files
committed
Updated scripts to satisfy Pylint rules
1 parent c93fb4d commit 83776f2

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1+
""" Script to Return the number of unread mails """
2+
3+
import os
14
from os import system
25
import imaplib
36
import getpass
7+
48
def speak(stuff):
9+
""" Use the system say function to speak out the message below """
510
system('say You have '+stuff+' unread emails')
611

7-
def get_unread_count(username,password):
8-
obj = imaplib.IMAP4_SSL('imap.gmail.com','993')
9-
obj.login(username,password)
12+
def get_unread_count(username, password):
13+
""" Return the number of unread mails """
14+
obj = imaplib.IMAP4_SSL('imap.gmail.com', '993')
15+
obj.login(username, password)
1016
obj.select('Inbox')
11-
typ, messageIDs = obj.search(None, "UNSEEN")
12-
listOfSplitStrings = str(messageIDs).split(" ")
13-
unread=len(listOfSplitStrings)
14-
speak(str(unread))
17+
message_ids = obj.search(None, "UNSEEN")[1]
18+
list_of_split_strings = str(message_ids).split(" ")
19+
unread = len(list_of_split_strings)
20+
# speak(str(unread))
1521
return unread
1622

17-
if __name__=="__main__":
18-
names=raw_input("Enter username:")
19-
password=getpass.getpass()
20-
unread = get_unread_count(names,password)
21-
print("You have "+str(unread)+" unread mails.")
22-
23-
24-
23+
if __name__ == "__main__":
24+
if "EMAIL_USERNAME" in os.environ and "DUMMY_PASSWORD" in os.environ:
25+
NAME = os.environ["EMAIL_USERNAME"]
26+
PASSWORD = os.environ["DUMMY_PASSWORD"]
27+
else:
28+
NAME = input("Enter username:")
29+
PASSWORD = getpass.getpass()
30+
UNREAD = get_unread_count(NAME, PASSWORD)
31+
print("You have "+str(UNREAD)+" unread mails.")

Random_Py_scripts/check_primes.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import sys
2-
def check_primes(n):
3-
primes_list=[]
4-
count=0
5-
for i in range(2,n):
6-
if n%i==0:
7-
count=count+1
8-
if count==0:
9-
return 0
10-
else:
1+
"""Script to return if a number is prime"""
2+
3+
def check_primes(num_to_check):
4+
"""
5+
Function to check if a number is prime
6+
"""
7+
count = 0
8+
for i in range(2, num_to_check):
9+
if num_to_check%i == 0:
10+
count = count+1
11+
if count == 0:
1112
return 1
12-
if __name__=="__main__":
13-
n=int(raw_input())
14-
cnt=check_primes(n)
15-
print cnt
16-
13+
return 0
14+
15+
if __name__ == "__main__":
16+
NUM = int(input())
17+
CNT = check_primes(NUM)
18+
print("Prime" if CNT == 1 else "Not Prime")

Random_Py_scripts/emails.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import smtplib
2-
fromaddr = 'abhi.darkness@gmail.com'
3-
toaddr = 'abhi.darkness@gmail.com'
4-
msg = "What's up"
5-
username = 'abhi.darkness@gmail.com'
6-
password = 'password'
7-
server = smtplib.SMTP('smtp.gmail.com:587')
8-
server.ehlo()
9-
server.starttls()
10-
server.login(username,password)
11-
server.sendmail(fromaddr,toaddr,msg)
12-
server.quit()
13-
14-
15-
16-
1+
''' Script to send a test mail'''
172

3+
import smtplib
4+
import os
185

6+
FROM_ADDR = 'abhi.darkness@gmail.com'
7+
TO_ADDR = 'abhi.darkness@gmail.com'
8+
MSG = "What's up2"
9+
USERNAME = 'abhi.darkness@gmail.com'
10+
PASSWORD = os.environ["DUMMY_PASSWORD"]
11+
SERVER = smtplib.SMTP('smtp.gmail.com:587')
12+
SERVER.ehlo()
13+
SERVER.starttls()
14+
SERVER.login(USERNAME, PASSWORD)
15+
SERVER.sendmail(FROM_ADDR, TO_ADDR, MSG)
16+
SERVER.quit()

0 commit comments

Comments
 (0)