-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
182 lines (158 loc) · 7.66 KB
/
app.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
178
179
180
181
182
import sys
import time
import automationModule
import easygui
from bs4 import BeautifulSoup
from splinter import Browser
from utils import fileReader, fileWriter
urls = list()
jobs = list()
if len(sys.argv) > 1:
if 'checkAtt' in sys.argv:
urls.append("https://webkiosk.jiit.ac.in/EmployeeFiles/PersonalInfo/SelfAttendanceDetail.jsp")
jobs.append('checkAtt')
elif 'pullAtt' in sys.argv:
urls.append("https://webkiosk.jiit.ac.in/EmployeeFiles/AcademicInfo/ViewAttendanceSummary11.jsp?SrcType=I")
jobs.append('pullAtt')
elif 'markAtt' in sys.argv:
urls.append("https://webkiosk.jiit.ac.in/EmployeeFiles/AcademicInfo/NewDailyStudentAttendanceEntry1.jsp")
jobs.append('markAtt')
elif 'createAtt' in sys.argv:
urls.append("https://webkiosk.jiit.ac.in/EmployeeFiles/AcademicInfo/NewDailyStudentAttendanceEntry1.jsp")
jobs.append('createAtt')
else:
print "Enter a valid argument"
exit(1)
else:
print "Provide argument/s\n"
exit(1)
(member_code, password) = fileReader.read()
if member_code is None or member_code is '':
member_code = easygui.enterbox("Enter Member Code:")
password = easygui.passwordbox()
fileWriter.write(member_code, password)
with Browser() as browser:
browser.visit("https://webkiosk.jiit.ac.in/")
browser.find_by_id('UserType').first.select('E')
browser.fill('MemberCode', member_code)
browser.fill('Password', password)
button = browser.find_by_name('BTNSubmit')
button.click()
if "Wrong Member" in browser.html:
print("Wrong Username/Password")
exit(1)
i = 0
while i < len(jobs):
browser.visit(urls[i])
if jobs[i] is 'pullAtt':
exam_choices = BeautifulSoup(browser.html, "html.parser").find(id='Exam').find_all("option")
exam_choices_list = list(exam_choice.attrs['value'] for exam_choice in exam_choices)
exam_choice_selected = easygui.choicebox(choices=exam_choices_list)
browser.find_by_id('Exam').first.select(exam_choice_selected)
subject_choices = BeautifulSoup(browser.html, "html.parser").find(id='Subject').find_all("option")
subject_choices_list = list(choice.attrs['value'] for choice in subject_choices)
subject_choice_selected = easygui.choicebox(choices=subject_choices_list)
browser.find_by_id('Subject').first.select(subject_choice_selected)
button = browser.find_by_value('Show/Refresh')
button.click()
if browser.status_code == 200:
if automationModule.activate(browser.html, job=jobs[i], fileNameID=subject_choice_selected):
easygui.msgbox(msg="Debar list created !!")
i += 1
elif jobs[i] is 'checkAtt':
button = browser.find_by_value('Show')
button.click()
if browser.status_code == 200:
easygui.msgbox(msg="You've been marked {0} for today !".format(
automationModule.activate(browser.html, job=jobs[i])))
i += 1
elif jobs[i] is 'markAtt':
import datetime
now = datetime.datetime.now()
if now.month <= 6:
sem = "EVE"
else:
sem = "ODD"
exam_choices = BeautifulSoup(browser.html, "html.parser").find(id='Exam').find_all("option")
exam_choices_list = list(exam_choice.attrs['value'] for exam_choice in exam_choices)
exam_choice_selected = None
for choice in exam_choices_list:
if str(now.year) in choice:
if sem in choice:
exam_choice_selected = choice
browser.find_by_id('Exam').first.select(exam_choice_selected)
subject_choices = BeautifulSoup(browser.html, "html.parser").find(id='Subject').find_all("option")
subject_choices_list = list(choice.attrs['value'] for choice in subject_choices)
subject_choice_selected = easygui.choicebox(choices=subject_choices_list)
browser.find_by_id('Subject').first.select(subject_choice_selected)
try:
(student_data, datetime_data) = automationModule.activate(browser.html, job=jobs[i],
fileNameID=subject_choice_selected)
except IOError:
student_data, datetime_data = None, None
easygui.msgbox('Please put the attendance sheet in the "AttendanceSheets" Folder!')
exit(1)
time_slot = datetime_data[3].split(";")
date1 = time_slot[0]
time1 = time_slot[1]
time2 = time_slot[2]
# Date to be provided within this block
browser.fill("qsysdate", str(date1))
button = browser.find_by_value('Submit')
button.click()
checkbox = browser.find_by_id('SubSection1').first
checkbox.check()
browser.fill("timepicker1", str(time1))
browser.fill("timepicker2", str(time2))
button = browser.find_by_value('Show/Refresh')
button.click()
if browser.status_code == 200:
soup = BeautifulSoup(browser.html, "html.parser")
student_attendance_rows = soup.find(id="table-1").find("tbody").find_all("tr")
j = 1
browser.find_by_id('allbox1').check()
for student_attendance_row in student_attendance_rows:
try:
if student_data[student_attendance_row.contents[1].contents[0]] is True:
browser.find_by_id('Present' + str(j)).first.check()
else:
pass
j += 1
except IndexError:
pass
break
# TODO final submit button click to be added only at Project Completion and final Delivery
time.sleep(10)
i += 1
elif jobs[i] is 'createAtt':
import datetime
now = datetime.datetime.now()
if now.month <= 6:
sem = "EVE"
else:
sem = "ODD"
exam_choices = BeautifulSoup(browser.html, "html.parser").find(id='Exam').find_all("option")
exam_choices_list = list(exam_choice.attrs['value'] for exam_choice in exam_choices)
exam_choice_selected = None
for choice in exam_choices_list:
if str(now.year) in choice:
if sem in choice:
exam_choice_selected = choice
browser.find_by_id('Exam').first.select(exam_choice_selected)
subject_choices = BeautifulSoup(browser.html, "html.parser").find(id='Subject').find_all("option")
subject_choices_list = list(choice.attrs['value'] for choice in subject_choices)
subject_choice_selected = easygui.choicebox(choices=subject_choices_list)
browser.find_by_id('Subject').first.select(subject_choice_selected)
button = browser.find_by_value('Submit')
button.click()
checkbox = browser.find_by_id('SubSection1').first
checkbox.check()
browser.fill("timepicker1", "09:00")
browser.fill("timepicker2", "10:00")
button = browser.find_by_value('Show/Refresh')
button.click()
if browser.status_code == 200:
if automationModule.activate(browser.html, job=jobs[i], fileNameID=subject_choice_selected):
easygui.msgbox(msg="Attendance list created !!")
i += 1
exit(0)