Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 538e319

Browse files
Merge branch 'avinashkranjan:master' into master
2 parents 1a29922 + 9962dd7 commit 538e319

File tree

224 files changed

+32480
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+32480
-19
lines changed

‎.github/workflows/database_auto_updater.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python package
1+
name: DataBase Updater
22

33
on:
44
pull_request:

‎Address-Book/Readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ADDRESS-BOOK
2+
3+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
4+
5+
This project is to create an Address book using python in which the user can add a new contact, edit and delete existing contact and view all the contact using Tkinter and SQlite.
6+
Tkinter library for rendering graphics and SQlite is used for database.
7+
8+
## Usage
9+
* In this python project, the user has button functionality to trigger that specific function.
10+
* eg –To edit a contact, the user has to fill the Name, phone no field and then click on edit button.
11+
To add a new contact,the user has to to fill the Name, phone no field and then click on add button.
12+
13+
## Output :smiley:
14+
<img width="528" alt="figure" src="https://user-images.githubusercontent.com/59785217/119015721-cf6ac700-b9b6-11eb-8aad-37f8665cda7c.png">
15+
16+
## Authors
17+
Written by [sameeksharl](https://www.github.com/sameeksharl)
18+
19+
The project was built as a contribution during [GSSOC'21](https://gssoc.girlscript.tech/).

‎Address-Book/addressbook.py

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
'''
2+
importing all the required libraries
3+
'''
4+
import sqlite3
5+
from sqlite3 import Error
6+
from tkinter import *
7+
import tkinter.messagebox
8+
root = Tk()
9+
root.geometry('600x370')
10+
list_of_names=[]
11+
root.title('AddressBook')
12+
Name = StringVar()
13+
Number = StringVar()
14+
15+
""" creating a database connection to the SQLite database
16+
specified by db_file
17+
return: Connection object or None
18+
"""
19+
def create_connection(db_file):
20+
conn = None
21+
try:
22+
conn = sqlite3.connect(db_file)
23+
r_set=conn.execute('''SELECT * from tasks''');
24+
for student in r_set:
25+
list_of_names.append(student[1])
26+
return conn
27+
except Error as e:
28+
print(e)
29+
return conn
30+
31+
""" create a table from the create_table_sql statement
32+
conn: Connection object
33+
create_table_sql: a CREATE TABLE statement
34+
"""
35+
def create_table(conn, create_table_sql):
36+
try:
37+
c = conn.cursor()
38+
c.execute(create_table_sql)
39+
except Error as e:
40+
print(e)
41+
return
42+
43+
'''
44+
displaying added/deleted message
45+
'''
46+
def onClickAdded():
47+
tkinter.messagebox.showinfo(" ",Name.get()+" got added")
48+
49+
def onClickDeleted():
50+
tkinter.messagebox.showinfo(" ",Name.get()+" got deleted")
51+
52+
""" Create a new task (ie creating new row) for the given Name taking care of all conditions such as Name,phone no
53+
cannot be empty ,phone no should be 10 digits and also if Name already exist,then it cannot be inerted
54+
"""
55+
def create_task():
56+
sql = ''' INSERT INTO tasks(name,status_id)
57+
VALUES(?,?) '''
58+
if(Name.get() not in list_of_names):
59+
60+
if((Name.get()=='') | (Number.get()=='') | (len(Number.get())!=10)):
61+
top = Toplevel(root)
62+
top.geometry('180x100')
63+
if((Number.get()=='') | (len(Number.get())!=10)):
64+
myLabel = Label(top, text="Phone no should be 10 digits\n")
65+
else:
66+
myLabel = Label(top, text="NAME IS EMPTY\n")
67+
myLabel.pack()
68+
mySubmitButton = Button(top, text=' Back ', command=top.destroy)
69+
mySubmitButton.pack()
70+
return
71+
onClickAdded()
72+
cur = conn.cursor()
73+
cur.execute(sql, (Name.get(),Number.get()))
74+
conn.commit()
75+
return cur.lastrowid
76+
else:
77+
top = Toplevel(root)
78+
top.geometry('180x100')
79+
if(Name.get()==''):
80+
myLabel = Label(top, text="NAME IS EMPTY\n")
81+
elif((Number.get()=='') | (len(Number.get())!=10)):
82+
myLabel = Label(top, text="Phone no should be 10 digits\n")
83+
else:
84+
myLabel = Label(top, text=Name.get()+" Already Exist\n")
85+
myLabel.pack()
86+
mySubmitButton = Button(top, text=' Back ', command=top.destroy)
87+
mySubmitButton.pack()
88+
89+
"""
90+
Query tasks by Name, if name not found then it gives a warning saying "NOT Found"
91+
"""
92+
def select_task_by_name():
93+
cur = conn.cursor()
94+
cur.execute("SELECT * FROM tasks WHERE name=?", (Name.get(),))
95+
rows = cur.fetchall()
96+
if(len(rows)==0):
97+
inputDialog = MyDialog(root)
98+
root.wait_window(inputDialog.top)
99+
else:
100+
Number.set(rows[0][2])
101+
102+
"""
103+
Editing phone no, if name not found then it gives a warning saying "NOT Found"
104+
"""
105+
def update_task():
106+
"""
107+
update priority, begin_date, and end date of a task
108+
:param conn:
109+
:param task:
110+
:return: project id
111+
"""
112+
sql = ''' UPDATE tasks
113+
SET status_id = ?
114+
WHERE name = ?'''
115+
if((Name.get() not in list_of_names) | (Name.get()=='')):
116+
inputDialog = MyDialog(root)
117+
root.wait_window(inputDialog.top)
118+
return
119+
cur = conn.cursor()
120+
cur.execute(sql, (Number.get(),Name.get()))
121+
conn.commit()
122+
123+
"""
124+
Delete a task by name.if not found ,gives a warning!!!
125+
"""
126+
def delete_task():
127+
if((Name.get() not in list_of_names) | (Name.get()=='')):
128+
inputDialog = MyDialog(root)
129+
root.wait_window(inputDialog.top)
130+
return
131+
onClickDeleted()
132+
sql = 'DELETE FROM tasks WHERE name=?'
133+
cur = conn.cursor()
134+
cur.execute(sql, (Name.get(),))
135+
conn.commit()
136+
137+
"""
138+
Get all rows in the tasks table
139+
"""
140+
def select_all_tasks():
141+
r_set=conn.execute('''SELECT * from tasks''');
142+
i=0
143+
j=0
144+
top = Toplevel(root)
145+
for student in r_set:
146+
list_of_names.append(student[1])
147+
for j in range(len(student)):
148+
e = Entry(top, width=11, fg='Gray20')
149+
e.grid(row=i, column=j)
150+
e.insert(END, student[j])
151+
i=i+1
152+
okButton= Button(top, text=' ok ', command=top.destroy)
153+
if(j==0):
154+
j=1
155+
okButton.grid(row=i+3, column=j-1)
156+
157+
'''
158+
Getting the path of database and defining the table to be created
159+
'''
160+
database = r"./Address-Book/addressbook.db"
161+
sql_create_tasks_table = """CREATE TABLE IF NOT EXISTS tasks (
162+
id integer PRIMARY KEY,
163+
name text NOT NULL,
164+
status_id integer NOT NULL
165+
166+
);"""
167+
168+
'''
169+
Creating connection and gives error message if connection failed
170+
'''
171+
conn = create_connection(database)
172+
if conn is not None:
173+
create_table(conn, sql_create_tasks_table)
174+
else:
175+
print("Error! cannot create the database connection.")
176+
177+
'''
178+
creating dialog box for warnings!
179+
'''
180+
class MyDialog:
181+
def __init__(self, parent):
182+
top = self.top = Toplevel(parent)
183+
self.myLabel = Label(top, text=Name.get().upper()+" NOT FOUND!")
184+
self.myLabel.pack()
185+
self.mySubmitButton = Button(top, text='Exit', command=self.send)
186+
self.mySubmitButton.pack()
187+
188+
def send(self):
189+
self.top.destroy()
190+
191+
'''
192+
Exiting from the application
193+
'''
194+
def EXIT():
195+
root.destroy()
196+
197+
'''
198+
Resetting Name and phone no field
199+
'''
200+
def RESET():
201+
Name.set('')
202+
Number.set('')
203+
204+
'''
205+
Creating UI for whole application
206+
'''
207+
Label(root, text = 'NAME', font='Times 15 bold').place(x= 130, y=20)
208+
Entry(root, textvariable = Name,width=42).place(x= 200, y=25)
209+
Label(root, text = 'PHONE NO ', font='Times 15 bold').place(x= 130, y=70)
210+
Entry(root, textvariable = Number,width=35).place(x= 242, y=73)
211+
Button(root,text=" ADD", font='Times 14 bold',bg='dark gray', command = create_task,width=8).place(x= 130, y=110)
212+
Button(root,text="EDIT", font='Times 14 bold',bg='dark gray',command = update_task,width=8).place(x= 260, y=108)
213+
Button(root,text="DELETE", font='Times 14 bold',bg='dark gray',command = delete_task,width=8).place(x= 390, y=107.5)
214+
Button(root,text="VIEW ALL", font='Times 14 bold',bg='dark gray', command = select_all_tasks,width=12).place(x= 160, y=191)
215+
Button(root,text="VIEW BY NAME", font='Times 14 bold',bg='dark gray', command = select_task_by_name,width=13).place(x= 330, y=190)
216+
Button(root,text="EXIT", font='Times 14 bold',bg='dark gray', command = EXIT,width=8).place(x= 200, y=280)
217+
Button(root,text="RESET", font='Times 14 bold',bg='dark gray', command = RESET,width=8).place(x= 320, y=280)
218+
root.mainloop()

‎Amazon-Price-Alert/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ requests-html==0.10.0
1616
six==1.15.0
1717
soupsieve==2.0.1
1818
tqdm==4.49.0
19-
urllib3==1.25.10
19+
urllib3==1.26.5
2020
w3lib==1.22.0
21-
websockets==8.1
21+
websockets==9.1

‎Audio_Steganography/Algos/Decrypt.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import os
2+
import wave
3+
import simpleaudio as sa
4+
import numpy as np
5+
from scipy.io import wavfile
6+
import binascii
7+
8+
"""
9+
10+
[NOTE] In this decryption algorithm we simply read the path of the audio from the user and we
11+
get a numpy array from the same. We then read the LSB of the binary representation of the data and get a string
12+
of binary data. Finally we convert this string to ascii charecters and write it to a file.
13+
14+
"""
15+
16+
17+
class Decrypt:
18+
19+
def __init__(self, audio_path):
20+
self.audio_path = audio_path
21+
self.audio_wave_obj = wave.open(audio_path)
22+
23+
"""
24+
This function is there for playing audio.
25+
"""
26+
27+
def play_audio(self) -> None:
28+
29+
playing = sa.WaveObject.from_wave_read(self.audio_wave_obj)
30+
obj = playing.play()
31+
32+
if obj.is_playing():
33+
print(f"Playing audio")
34+
35+
obj.wait_done()
36+
37+
"""
38+
The decryption is done here.
39+
"""
40+
41+
def decrypt_audio(self, output_dir: str, file_name: str, gen_file_status: bool) -> (str, bool):
42+
if gen_file_status:
43+
curr_dir_path = os.getcwd()
44+
output_dir_path = os.path.join(curr_dir_path, output_dir)
45+
46+
try:
47+
os.mkdir(output_dir_path)
48+
except:
49+
pass
50+
51+
print(f"This might take some while if your secret message is big and might contain some rubbish data.")
52+
53+
# Reading the data from the wav file
54+
samplerate, data = wavfile.read(self.audio_path)
55+
m, n = data.shape
56+
# Reshaping it to make the data easier to handle
57+
data_reshaped = data.reshape(m*n, 1)
58+
59+
s = ""
60+
zeros = 0
61+
62+
# Getting the LSB from each number
63+
for i in range(m*n):
64+
t = str(data_reshaped[i][0] & 1)
65+
if zeros < 9:
66+
s += t
67+
else:
68+
break
69+
if t == '0':
70+
zeros += 1
71+
if t == '1':
72+
zeros = 0
73+
74+
# Making sure the bit-string is of length divisible by 8 as we have stored the input-secret as 8-bits only
75+
s = s[:((len(s)//8)*8)]
76+
77+
# Converting bbinary string to utf-8
78+
in_bin = int(s, 2)
79+
byte_num = in_bin.bit_length() + 7 // 8
80+
bin_arr = in_bin.to_bytes(byte_num, "big")
81+
result = bin_arr.decode("utf-8", "ignore")
82+
83+
# Writing to output file if status was given true
84+
if gen_file_status:
85+
try:
86+
with open(os.path.join(output_dir_path, file_name), "w", encoding="utf-8") as f:
87+
f.write(result)
88+
print("Success !!!")
89+
return result, True
90+
except:
91+
print(("Error !!!"))
92+
pass
93+
return None, False
94+
else:
95+
return result, True

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /