-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExit_Qr_Making.py
177 lines (137 loc) · 6.03 KB
/
Exit_Qr_Making.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#Exit QR making
import pyrebase
from datetime import datetime
import qrcode
firebaseConfig = {
'apiKey': "AIzaSyBFidAWIw-UggFx49xbXLunkXW5-_c1Ywo",
'authDomain': "entryexittagglogdb.firebaseapp.com",
'projectId': "entryexittagglogdb",
'storageBucket': "entryexittagglogdb.appspot.com",
'messagingSenderId': "898361353579",
'appId': "1:898361353579:web:924cc29e68e3522c80d82e",
'measurementId': "G-PWFZBQG312",
'databaseURL':'https://entryexittagglogdb-default-rtdb.firebaseio.com'
}
firebase = pyrebase.initialize_app(firebaseConfig)
db = firebase.database()
made = 0
print("Checking for any ActiveStatus in Database!!")
#create a function to check the active status available or not
#retrive all usn and check witht he usn by usnig some functions
#and pass to Exitqe
def intial_usn_check(stud_usn_check1):
print("Dfgdf")
try:
check_usn(stud_usn_check1)
except:
print("Sorry In Databse You Haven't Made Any Entry!! Try Making Any Entry ;]")
def check_usn(stud_usn_check):
users = db.child(stud_usn_check).get()
print(users.val())
#creating a list
stud_key_list = []
#establishing a flag to know it is active or not,active na 1.or 0
active = 0
active_db_key = ''
# creating a dict
stud_dict = {}
for user in users.each():
print("Came to For loop ")
print(user.key())
stud_key_identification = user.key()
print(stud_key_identification)
stud_key_list.append(stud_key_identification)
print(stud_key_list)
stud_outtime_check = db.child(stud_usn_check).child(stud_key_identification).get()
print(stud_outtime_check)
print("Retreived the available keys")
for stud_in_time in stud_outtime_check.each():
# print(stud_in_time.key(),stud_in_time.val())
stud_dict[stud_in_time.key()] = stud_in_time.val()
print(stud_dict)
b = 'In*Time'
if b in stud_dict.keys():
print("Present")
inactive_db()
else:
print("Not present")
active = 1
active_db_key = stud_dict.get("Key")
active_db(stud_usn_check, active_db_key)
#after it will be empty and so we can define new Dictionary to check!
stud_dict = {}
def active_db(stud_fk_usn,stud_fk_key):
print("Fked up here")
print(stud_fk_key,stud_fk_usn)
#need to satrt code from here
Exitqr(stud_fk_usn,stud_fk_key)
def inactive_db():
print("All Database are Inactive:")
print("So you Didn't Make Any Entry!! ;]")
def Exitqr(stud_usn, stud_key):
print("Entered here")
print(stud_usn)
made = 0
stud_details = db.child(stud_usn).child(stud_key).get()
stud_db_acc_dict = {}
try:
for stud_db_acc in stud_details.each():
print(stud_db_acc.key(),stud_db_acc.val())
if (stud_db_acc.key() == "Name"):
stud_name_db = stud_db_acc.val()
stud_db_acc_dict["Name"] = stud_name_db
elif (stud_db_acc.key() == "USN"):
stud_USN_db = stud_db_acc.val()
stud_db_acc_dict["USN"] = stud_USN_db
elif (stud_db_acc.key() == "sem"):
stud_sem_db = stud_db_acc.val()
stud_db_acc_dict["sem"] = stud_sem_db
elif (stud_db_acc.key() == "Branch"):
stud_branch_db = stud_db_acc.val()
stud_db_acc_dict["Branch"] = stud_branch_db
elif (stud_db_acc.key() == "Mobileno"):
stud_mobilno_db = stud_db_acc.val()
stud_db_acc_dict["Mobileno"] = stud_mobilno_db
elif (stud_db_acc.key() == "Out*Time"):
stud_Time_db = stud_db_acc.val()
stud_db_acc_dict["Out*Time"] = stud_Time_db
elif (stud_db_acc.key() == "reason"):
stud_reason_db = stud_db_acc.val()
stud_db_acc_dict["reason"] = stud_reason_db
elif (stud_db_acc.key() == "time*day"):
stud_td_db = stud_db_acc.val()
stud_db_acc_dict["time*day"] = stud_td_db
elif (stud_db_acc.key() == "Out*Date"):
stud_date_db = stud_db_acc.val()
stud_db_acc_dict["Out*Date"] = stud_date_db
elif (stud_db_acc.key() == "Key"):
stud_key_db = stud_db_acc.val()
stud_db_acc_dict["Key"] = stud_key_db
elif (stud_db_acc.key() == "emailid"):
stud_emailid = stud_db_acc.val()
stud_db_acc_dict["emailid"] = stud_emailid
print("email mff:"+stud_emailid)
except:
print("Retreving finished")
# getting date and time when they logged in
stud_time = datetime.today().strftime("%H:%M:%S %p")
print(stud_time)
now = datetime.now()
stud_date = now.strftime("%d-%m-%y")
print(stud_date)
# adding the date and time to dictionary
stud_db_acc_dict["In*Date"] = stud_date
stud_db_acc_dict["In*Time"] = stud_time
# after inserting date and time
print(stud_db_acc_dict)
#need to make a QR Here
stud_qr_random = qrcode.QRCode(version=3, error_correction=qrcode.ERROR_CORRECT_M
, box_size=10, border=4)
stud_qr_random.add_data(stud_db_acc_dict)
stud_qr_random.make(fit=True)
stud_qrrr = stud_qr_random.make_image(fill_color='black', back_color='blue')
stud_QR = stud_qrrr.save(r'D:\\PyCharm\\PycharmProjects\\EntryExit_QR\\Students_generated_qrcodes\\exit.jpg')
print("Random Exit QR had made successfully")
# except:
# print("OOPS! Sorry u didn't Make any Entry Log!!")
#need to generate a random key after usn.