Skip to content

Commit

Permalink
Format code with autopep8
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 5bfb399 according to the output
from autopep8.

Details: https://deepsource.io/gh/avinashkranjan/Amazing-Python-Scripts/transform/cde918ce-12ee-455a-a397-6e343a1a9f1b/
  • Loading branch information
deepsource-autofix[bot] authored Apr 20, 2021
1 parent 5bfb399 commit 63b7450
Show file tree
Hide file tree
Showing 144 changed files with 5,576 additions and 4,865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def lambda_handler(event, context):
instances = Ec2Instances(region_name)
deleted_counts = instances.delete_snapshots(1)
instances.delete_available_volumes()
print("deleted_counts for region " + str(region_name) + " is " + str(deleted_counts))
print("deleted_counts for region " +
str(region_name) + " is " + str(deleted_counts))
instances.shutdown()
print("For RDS")
rds = Rds(region_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

def get_delete_data(older_days):
delete_time = datetime.now(tz=timezone.utc) - timedelta(days=older_days)
return delete_time;
return delete_time


def is_ignore_shutdown(tags):
for tag in tags:
print("K " + str(tag['Key']) + " is " + str(tag['Value']))
if str(tag['Key']) == 'excludepower' and str(tag['Value']) == 'true':
print("Not stopping K " + str(tag['Key']) + " is " + str(tag['Value']))
print("Not stopping K " +
str(tag['Key']) + " is " + str(tag['Value']))
return True
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def _delete_instance_snapshot(self, identifier):
self.rds.delete_db_snapshot(DBSnapshotIdentifier=identifier)

def _delete_cluster_snapshot(self, identifier):
self.rds.delete_db_cluster_snapshot(DBClusterSnapshotIdentifier=identifier)
self.rds.delete_db_cluster_snapshot(
DBClusterSnapshotIdentifier=identifier)

@staticmethod
def _can_delete_instance(tags):
Expand Down Expand Up @@ -88,7 +89,8 @@ def _cleanup_snapshots_clusters(self):
if self._can_delete_snapshot(tags) and self._is_older_snapshot(
str(snapshot['SnapshotCreateTime']).split(" ")):
try:
self._delete_cluster_snapshot(snapshot['DBClusterSnapshotIdentifier'])
self._delete_cluster_snapshot(
snapshot['DBClusterSnapshotIdentifier'])
except Exception as e:
print(str(e))

Expand All @@ -99,14 +101,16 @@ def _cleanup_snapshot_instance(self):
if self._can_delete_snapshot(tags) and self._is_older_snapshot(
str(snapshot['SnapshotCreateTime']).split(" ")):
try:
self._delete_instance_snapshot(snapshot['DBSnapshotIdentifier'])
self._delete_instance_snapshot(
snapshot['DBSnapshotIdentifier'])
except Exception as e:
print(str(e))

@staticmethod
def _is_older_snapshot(snapshot_datetime):
snapshot_date = snapshot_datetime[0].split("-")
snapshot_date = datetime.date(int(snapshot_date[0]), int(snapshot_date[1]), int(snapshot_date[2]))
snapshot_date = datetime.date(int(snapshot_date[0]), int(
snapshot_date[1]), int(snapshot_date[2]))
today = datetime.date.today()
if abs(today - snapshot_date).days > 2:
return True
Expand Down
16 changes: 10 additions & 6 deletions Age-Calculator-GUI/age_calc_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
# initialized window
root = Tk()
root.geometry('280x300')
root.resizable(0,0)
root.resizable(0, 0)
root.title('Age Calculator')
statement = Label(root)

# defining the function for calculating age


def ageCalc():
global statement
statement.destroy()
today = date.today()
birthDate = date(int(yearEntry.get()), int(monthEntry.get()), int(dayEntry.get()))
birthDate = date(int(yearEntry.get()), int(
monthEntry.get()), int(dayEntry.get()))
age = today.year - birthDate.year
if today.month < birthDate.month or today.month == birthDate.month and today.day < birthDate.day:
age -= 1
statement = Label(text=f"{nameValue.get()}'s age is {age}.")
statement.grid(row=6, column=1, pady=15)


# creating a label for person's name to display
l1 = Label(text = "Name: ")
l1 = Label(text="Name: ")
l1.grid(row=1, column=0)
nameValue = StringVar()

Expand All @@ -31,21 +35,21 @@ def ageCalc():
nameEntry.grid(row=1, column=1, padx=10, pady=10)

# label for year in which user was born
l2 = Label(text = "Year: ")
l2 = Label(text="Year: ")
l2.grid(row=2, column=0)
yearValue = StringVar()
yearEntry = Entry(root, textvariable=yearValue)
yearEntry.grid(row=2, column=1, padx=10, pady=10)

# label for month in which user was born
l3 = Label(text = "Month: ")
l3 = Label(text="Month: ")
l3.grid(row=3, column=0)
monthValue = StringVar()
monthEntry = Entry(root, textvariable=monthValue)
monthEntry.grid(row=3, column=1, padx=10, pady=10)

# label for day/date on which user was born
l4 = Label(text = "Day: ")
l4 = Label(text="Day: ")
l4.grid(row=4, column=0)
dayValue = StringVar()
dayEntry = Entry(root, textvariable=dayValue)
Expand Down
36 changes: 18 additions & 18 deletions Air pollution prediction/CodeAP.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@
iaqi = data['iaqi']



for i in iaqi.items():
print(i[0],':',i[1]['v'])
dew = iaqi.get('dew','Nil')
no2 = iaqi.get('no2','Nil')
o3 = iaqi.get('o3','Nil')
so2 = iaqi.get('so2','Nil')
pm10 = iaqi.get('pm10','Nil')
pm25 = iaqi.get('pm25','Nil')

print(f'{city} AQI :',aqi,'\n')
print(i[0], ':', i[1]['v'])
dew = iaqi.get('dew', 'Nil')
no2 = iaqi.get('no2', 'Nil')
o3 = iaqi.get('o3', 'Nil')
so2 = iaqi.get('so2', 'Nil')
pm10 = iaqi.get('pm10', 'Nil')
pm25 = iaqi.get('pm25', 'Nil')

print(f'{city} AQI :', aqi, '\n')
print('Individual Air quality')
print('Dew :',dew)
print('no2 :',no2)
print('Ozone :',o3)
print('sulphur :',so2)
print('pm10 :',so2)
print('pm25 :',pm25)
print('Dew :', dew)
print('no2 :', no2)
print('Ozone :', o3)
print('sulphur :', so2)
print('pm10 :', so2)
print('pm25 :', pm25)
pollutants = [i for i in iaqi]
values = [i['v'] for i in iaqi.values()]

Expand All @@ -39,8 +38,9 @@
explode[mx] = 0.1

# Plot a pie chart
plt.figure(figsize=(8,6))
plt.pie(values, labels=pollutants,explode=explode,autopct='%1.1f%%', shadow=True)
plt.figure(figsize=(8, 6))
plt.pie(values, labels=pollutants, explode=explode,
autopct='%1.1f%%', shadow=True)

plt.title('Air pollutants and their probable amount in atmosphere [kanpur]')

Expand Down
32 changes: 18 additions & 14 deletions Applying Bitwise Operations/Applying Bitwise operations.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import cv2

src1= input("Enter the path of the image 1\n") #getting the path for first image
src1 = cv2.imread(src1)
#src1 = cv2.resize(src1,(540,540)) #resizing the image
src2 = input("Enter the path of the image 2\n") #getting the path for second image
# getting the path for first image
src1 = input("Enter the path of the image 1\n")
src1 = cv2.imread(src1)
# src1 = cv2.resize(src1,(540,540)) #resizing the image
# getting the path for second image
src2 = input("Enter the path of the image 2\n")
src2 = cv2.imread(src2)

src2 = cv2.resize(src2, src1.shape[1::-1]) #Resizing the image so that both images have same dimensions
andop= cv2.bitwise_and(src1, src2,mask=None) #Applying Bitwise AND operation
andop=cv2.resize(andop,(640,640))
cv2.imshow('Bitwise AND',andop)
# Resizing the image so that both images have same dimensions
src2 = cv2.resize(src2, src1.shape[1::-1])
# Applying Bitwise AND operation
andop = cv2.bitwise_and(src1, src2, mask=None)
andop = cv2.resize(andop, (640, 640))
cv2.imshow('Bitwise AND', andop)

orop= cv2.bitwise_or(src1, src2,mask=None) #Applying Bitwise OR operation
orop=cv2.resize(orop,(640,640))
cv2.imshow('Bitwise OR',orop)
orop = cv2.bitwise_or(src1, src2, mask=None) # Applying Bitwise OR operation
orop = cv2.resize(orop, (640, 640))
cv2.imshow('Bitwise OR', orop)

xorop = cv2.bitwise_xor(src1,src2,mask=None) #Applying Bitwise OR operation
xorop=cv2.resize(xorop,(640,640))
cv2.imshow('Bitwise XOR',xorop)
xorop = cv2.bitwise_xor(src1, src2, mask=None) # Applying Bitwise OR operation
xorop = cv2.resize(xorop, (640, 640))
cv2.imshow('Bitwise XOR', xorop)
cv2.waitKey(0)
cv2.destroyAllWindows()
26 changes: 15 additions & 11 deletions Attachment_Downloader/attachment.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
import ezgmail


def attachmentdownload(resulthreads):
# Two Objects used in code are GmailThread and GmailMessage
# 1. GmailThread - Represents conversation threads
# 2. GmailMessage - Represents individual emails within Threads
countofresults = len(resulthreads)
try:
for i in range(countofresults):
if len(resulthreads[i].messages) > 1: # checks whether the count of messages in threads is greater than 1
# checks whether the count of messages in threads is greater than 1
if len(resulthreads[i].messages) > 1:
for j in range(len(resulthreads[i].messages)):
resulthreads[i].messages[
j].downloadAllAttachments() # downloads attachment(s) for individual messages
else:
resulthreads[i].messages[0].downloadAllAttachments() # downloads attachment(s) for single message
# downloads attachment(s) for single message
resulthreads[i].messages[0].downloadAllAttachments()
print("Download compelete. Please check your root directory.")
except:
raise Exception("Error occured while downloading attachment(s).")


if __name__ == '__main__':
query = input("Enter search query: ")
newquery = query + " + has:attachment" # appending to make sure the result threads always has an attachment
resulthreads = ezgmail.search(newquery) # search functions accepts all the operators described at https://support.google.com/mail/answer/7190?hl=en
# appending to make sure the result threads always has an attachment
newquery = query + " + has:attachment"
# search functions accepts all the operators described at https://support.google.com/mail/answer/7190?hl=en
resulthreads = ezgmail.search(newquery)

if len(resulthreads) == 0:
print("Result has no attachments:") # Executed if results don't have attachment
# Executed if results don't have attachment
print("Result has no attachments:")
else:
print("Result(s) with attachments:")
for threads in resulthreads:
print(f"Email Subject: {threads.messages[0].subject}") # prints the subject line of email thread in results
# prints the subject line of email thread in results
print(f"Email Subject: {threads.messages[0].subject}")
try:
ask = input(
"Do you want to download attachment(s) in result(s) (Yes/No)? ") # Allows user to decide whether they want to download attachment(s) or not
if ask == "Yes":
attachmentdownload(resulthreads) # calls the function that downloads attachment(s)
# calls the function that downloads attachment(s)
attachmentdownload(resulthreads)
else:
print("Program exited")
except:
print("Something went wrong")




33 changes: 22 additions & 11 deletions Auto Birthday Wisher/Auto B'Day Wisher.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import pandas as pd # Pandas library is used for importing and reading the data
import datetime # datetime module is used for fetching the dates
# Pandas library is used for importing and reading the data
import pandas as pd
# datetime module is used for fetching the dates
import datetime
import smtplib # smtp library used for sending mail
import os

current_path = os.getcwd()
print(current_path)
os.chdir(current_path) # Changing the Path of the directory in which you are currently working
# Changing the Path of the directory in which you are currently working
os.chdir(current_path)

GMAIL_ID = input("Enter your email: ") # Give your mail here from which you want to send the wishes
GMAIL_PSWD = input("Enter password for your email mentioned above: ") # Give your mail password
# Give your mail here from which you want to send the wishes
GMAIL_ID = input("Enter your email: ")
# Give your mail password
GMAIL_PSWD = input("Enter password for your email mentioned above: ")


def sendEmail(to, sub, msg):
print(f"Email to {to} sent: \nSubject: {sub} ,\nMessage: {msg}")
s = smtplib.SMTP('smtp.gmail.com', 587) # creating server to send mail
s.starttls() # start a TLS session
s.login(GMAIL_ID, GMAIL_PSWD) # the function will login with your Gmail credentials
s.sendmail(GMAIL_ID, to, f"Subject: {sub} \n\n {msg}") # sending the mail
# creating server to send mail
s = smtplib.SMTP('smtp.gmail.com', 587)
# start a TLS session
s.starttls()
# the function will login with your Gmail credentials
s.login(GMAIL_ID, GMAIL_PSWD)
# sending the mail
s.sendmail(GMAIL_ID, to, f"Subject: {sub} \n\n {msg}")
s.quit()


if __name__ == "__main__":
df = pd.read_excel("data.xlsx") # the datasheet where the data of the friends is stored
# the datasheet where the data of the friends is stored
df = pd.read_excel("data.xlsx")
today = datetime.datetime.now().strftime("%d-%m")
yearNow = datetime.datetime.now().strftime("%Y")

Expand All @@ -31,7 +41,8 @@ def sendEmail(to, sub, msg):
bday = datetime.datetime.strptime(bday, "%d-%m-%Y")
bday = bday.strftime("%d-%m")
if(today == bday) and yearNow not in str(item['LastWishedYear']):
sendEmail(item['Email'], "Happy Birthday", item['Dialogue']) # calling the sendmail function
# calling the sendmail function
sendEmail(item['Email'], "Happy Birthday", item['Dialogue'])
writeInd.append(index)

if writeInd != None:
Expand Down
Loading

0 comments on commit 63b7450

Please sign in to comment.