-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_cron.py
57 lines (46 loc) · 1.67 KB
/
update_cron.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
'''
Created on 6 Oct 2014
@author: podero
scheduled as a cron job to process uploaded csv file data containing student allocation information.
'''
import ops
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import os
DIRECTORY = os.path.dirname(__file__)
_DEBUG = True
class MainHandler(webapp.RequestHandler):
def get(self):
data = ops.getData()
register = True
for dArr in data:
d = str(dArr.data)
dataArr = d.split('#')
count = 0
for record in dataArr:
recordArr = record.split(",")
regno = recordArr[0]
name =recordArr[1]
#othernames = recordArr[2]
gender = recordArr[2]
hostel = recordArr[3]
block = recordArr[4]
roomNo = recordArr[5]
roomtype = recordArr[6]
period = recordArr[7]
if register and count > 0:
ops.addPeriod(period,period)
register = False
ops.uploadTest(regno,name,gender,hostel,block,roomNo,roomtype,period)
ops.flagApplicant(regno.strip())
count = count + 1
class ApplicationHandler(webapp.RequestHandler):
def get(self):
if ops.applicationOpen():
ops.resetApplications()
def main():
application = webapp.WSGIApplication([('/cron/update_data', MainHandler),
('/cron/open_application', ApplicationHandler)], debug=True)
run_wsgi_app(application)
if __name__ == "__main__":
main()