compatibleSchedule = manager.findCompatibleSchedule(schedules, courseAvailability) #we found a better compatible schedule! if(compatibleSchedule.ID < rank): print "A better schedule is available" print compatibleSchedule #TODO: test take action, untested #try to update schedule if(takeAction): #create of list of classes we need to CHANGE #then add that list coursesToAdd = findUpdatedCourses(baseSchedule,compatible) success = True for crs in coursesToAdd: nav.addCourse(crs) added = manager.verfiyAdd(crs) #class add failed if added == False: success = False #try to revert schedule reverted = manager.revertSchedule(baseSchedule) #failed to revert back if reverted == False: #alert of failed revert critical issue currentSchedule = manager.checkCurrentSchedule() notify.notifyRevertFailed(baseSchedule,compatibleSchedule,currentSchedule) notify.sendEmail(recipient) #leave loop