bug fix/better comments/no_refresh option

This commit is contained in:
SowinskiBraeden committed 2022-08-18 00:02:49 -07:00
1 parent 9a6117963a
commit 0bad75a302
3 files changed
+87 -51

No files matched your search

+50 -10
View File
@@ -16,12 +16,12 @@ from scheduleGenerator.generator import generateScheduleV3
done = False
def processing():
def processing(msg: str):
for c in itertools.cycle(['|', '/', '-', '\\']):
if done: break
sys.stdout.write(f'\rProcessing {c}')
sys.stdout.flush()
sleep(0.1)
if done: break
sys.stdout.write(f'\r{msg} {c}')
sys.stdout.flush()
sleep(0.1)
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
# Error Table calulation / output
@@ -46,17 +46,57 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
if __name__ == '__main__':
if len(sys.argv) == 1:
print()
print('\nGenerating...\n')
st = time() # Start time
t = threading.Thread(target=processing)
t.start() # Start animation
t = threading.Thread(target=processing, args=('Collection student requests',))
t.start() # Start animation
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
samplemockCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
done = True # End Animation
print('\nStudent list generated.\n')
t = threading.Thread(target=processing, args=('Collection Course Information',))
done = False # reset animation
t.start() # Start animation
sampleCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
done = True # End Animation
print('\nCourse Information Collected.\n')
sleep(0.1)
t = threading.Thread(target=processing, args=('Processing',))
done = False # reset animation
t.start() # Start animation
timetable = {}
timetable["Version"] = 3
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
timetable["timetable"] = generateScheduleV3(sampleStudents, sampleCourses, 40, "./output/students.json", "./output/conflicts.json")
done = True # End Animation
et = time() # End time
elapsed_time = round((et - st), 3) # Execution time
print(f'\n\nDone - Finished in {elapsed_time} seconds\n')
errors, _, _ = errorOutput(sampleStudents)
print(errors)
elif sys.argv[1].lower() == "norefresh" or sys.argv[1].lower() == "no_refresh":
print('\nGenerating...\n')
st = time() # Start time
with open('./output/students.json') as f: sampleStudents = json.load(f)
with open('./output/courses.json') as f: sampleCourses = json.load(f)
for student in sampleStudents:
student["remainingAlts"] = []
for i in range(1, 11): student["schedule"][f"block{i}"] = []
student["classes"] = 0
t = threading.Thread(target=processing, args=('Processing',))
t.start() # Start animation
timetable = {}
timetable["Version"] = 3
timetable["timetable"] = generateScheduleV3(sampleStudents, sampleCourses, 40, "./output/students.json", "./output/conflicts.json")
done = True # End Animation
et = time() # End time