-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (31 loc) · 1.05 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
import sys
import os
import json
from student import Student
def file_exists(file):
return os.path.exists(file)
def first_time():
return not file_exists('marks.json')
def read_secrets():
if not file_exists('secrets.json'):
print('No secrets.json found, template can be found at '
'https://github.com/steynvl/su-marks/blob/master/secrets.json')
sys.exit(0)
with open('secrets.json', 'r') as secrets:
return json.load(secrets)
def main():
student = Student(read_secrets())
if first_time():
print('No marks.json found, fetching marks...')
student.scrape_marks()
student.write_marks_to_file()
print('Marks dumped to marks.json, next '
'time this program is ran it will check '
'if the marks have changed and then '
'notify the student.')
elif student.marks_have_changed():
student.write_marks_to_file()
print('Marks have changed, notifying student...')
student.notify()
if __name__ == '__main__':
main()