-
Notifications
You must be signed in to change notification settings - Fork 4
/
Main.py
executable file
·46 lines (41 loc) · 1.69 KB
/
Main.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
#!/usr/bin/env python2.7
#system
#JSON for language agnostic output
try:
import simplejson as json
except ImportError:
import json
#local
#AeriesSession provides an object for interacting with the Aeries
# website (also used internally by Gradebooks and Assignments)
#Gradebooks gets gradebook information from the home page
#Assignments gets assignment information from the home page
import AeriesSession, Gradebooks, Assignments, GradebookDetails
def get(what, email, password, gradebook=None):
try:
session = AeriesSession.Session(email, password)
except ValueError:
raise
if what == 'grades':
data = Gradebooks.getGradebooks(session)
if what == 'assignments':
data = Assignments.getAssignments(session)
if what == 'gradebook':
#gradebook is treated as a regular expression
data = GradebookDetails.getGradebook(gradebook, session)
json = toJSON(data)
return json
def getUserData(email, password):
#Initializes a session object, which logs in to Aeries
session = AeriesSession.Session(email, password)
#Passes the session object to the Gradebooks class to
# read general gradebook information (in python format)
# from the home page
gradebooks = Gradebooks.getGradebooks(session)
#Passes the session object to the Assignments class to read
# the current month's (starting on the 1st ending on the
# last day) assignments (in python format) from the home page
assignments = Assignments.getAssignments(session)
return {'gradebooks': gradebooks, 'assignments': assignments}
def toJSON(python_hierachy):
return json.dumps(python_hierachy, sort_keys=True, indent=4, separators=(',', ': '))