-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
124 lines (102 loc) · 4.46 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
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
import wx
import sys
import threading
from MainFrame import MainFrame
from algorithms import RoomAllotment
from algorithms.SeatingArrangement.main import start_seating_arrangement_process
from algorithms.Invigilation.main import start_invigilation_process
from algorithms.InvigilationReports.main import start_invig_report_generation
from algorithms.SeatingChart.main import generate_seating_charts
from algorithms.Mailer.main import send_mails
from algorithms.Mailer.login import login_mail_account
from xmlEditor import start_xml_editor
frame: MainFrame = None
app = None
def room_generate_btn_clicked(event):
is_double = frame.room_algorithm_radio.GetSelection() == 1
sys.stdout = frame.room_error_log_box
sys.stderr = frame.room_error_log_box
frame.room_error_log_box.ClearAll()
thread = threading.Thread(target=RoomAllotment.start_process, args=(
frame.room_csv_picker.GetPath(), frame.room_exam_csv_picker.GetPath(), is_double))
thread.start()
def seating_generate_btn_clicked(event):
sys.stdout = frame.seating_error_box
sys.stderr = frame.seating_error_box
frame.seating_error_box.ClearAll()
thread = threading.Thread(target=start_seating_arrangement_process, args=(
frame.seating_room_csv_picker.GetPath(), frame.seating_student_csv_picker.GetPath()))
thread.start()
def invig_generate_btn_clicked(event):
sys.stdout = frame.invig_error_box
sys.stderr = frame.invig_error_box
frame.invig_error_box.ClearAll()
reserve_duties = int(frame.invig_reserve_duties_box.GetValue())
cutoffs = [int(x)
for x in frame.invig_big_course_cutoffs_box.GetValue().split(",")]
thread = threading.Thread(target=start_invigilation_process, args=(
frame.invig_faculty_csv_picker.GetPath(),
frame.invig_scholar_csv_picker.GetPath(),
frame.invig_chamber_csv_picker.GetPath(),
frame.invig_timetable_csv_picker.GetPath(),
frame.invig_leaves_csv_picker.GetPath(),
frame.invig_duties_csv_picker.GetPath(),
frame.invig_room_csv_picker.GetPath(),
reserve_duties,
cutoffs
))
thread.start()
def report_config_clicked(event):
start_xml_editor()
def report_invig_generate_btn_clicked(event):
sys.stdout = frame.report_error_box
sys.stderr = frame.report_error_box
frame.report_error_box.ClearAll()
thread = threading.Thread(target=start_invig_report_generation, args=(
frame.report_invig_csv_picker.GetPath(),))
thread.start()
def report_generate_seat_charts_btn_clicked(event):
sys.stdout = frame.report_error_box
sys.stderr = frame.report_error_box
frame.report_error_box.ClearAll()
thread = threading.Thread(target=generate_seating_charts, args=(
frame.report_room_map_csv_picker.GetPath(),
frame.report_room_csv_picker.GetPath(),
frame.report_students_csv_picker.GetPath(),
frame.report_ic_csv_picker.GetPath()
))
thread.start()
def mailer_send_btn_clicked(event):
sys.stdout = frame.mailer_error_box
sys.stderr = frame.mailer_error_box
frame.mailer_error_box.ClearAll()
frame.mailer_send_btn.Disable()
thread = threading.Thread(target=send_mails, args=(
frame.mailer_subject_box.GetValue(), frame.mailer_body_box.GetValue(), frame.mailer_dir_picker.GetPath()))
thread.start()
def mailer_login_btn_clicked(event):
sys.stdout = frame.mailer_error_box
sys.stderr = frame.mailer_error_box
frame.mailer_error_box.ClearAll()
thread = threading.Thread(target=login_mail_account)
thread.start()
def mailer_dir_picker_changed(evnet):
frame.mailer_send_btn.Enable()
if __name__ == "__main__":
app = wx.App(False)
frame = MainFrame(None)
frame.room_generate_btn.Bind(wx.EVT_BUTTON, room_generate_btn_clicked)
frame.seating_generate_btn.Bind(
wx.EVT_BUTTON, seating_generate_btn_clicked)
frame.invig_generate_btn.Bind(wx.EVT_BUTTON, invig_generate_btn_clicked)
frame.report_config_btn.Bind(wx.EVT_BUTTON, report_config_clicked)
frame.report_invig_generate_btn.Bind(
wx.EVT_BUTTON, report_invig_generate_btn_clicked)
frame.mailer_send_btn.Bind(wx.EVT_BUTTON, mailer_send_btn_clicked)
frame.mailer_login_btn.Bind(wx.EVT_BUTTON, mailer_login_btn_clicked)
frame.mailer_dir_picker.Bind(
wx.EVT_DIRPICKER_CHANGED, mailer_dir_picker_changed)
frame.report_generate_seat_charts_btn.Bind(
wx.EVT_BUTTON, report_generate_seat_charts_btn_clicked)
frame.Show()
app.MainLoop()