def getSchedule(self, account, password, classroom, schedule_year, schedule_term):
     db = MysqlUse()
     i = 0
     sch = SchoolApiGet()
     res_schedule = sch.get_schedule_info(account, password, schedule_year, schedule_term)
     while 'schedule' not in res_schedule:
         res_schedule = sch.get_schedule_info(account, password, schedule_year, schedule_term)
         i = i + 1
         if i >= 4:
             return res_schedule
     for day in range(len(res_schedule['schedule'])):
         for lesson in range(len(res_schedule['schedule'][day])):
             for x in range(len(res_schedule['schedule'][day][lesson])):
                 res_sql = db.insertSchedule(res_schedule['schedule_year'],  res_schedule['schedule_term'], day, lesson, classroom,  res_schedule['schedule'][day][lesson][x])
                 if not res_sql:
                     return False
     return True
 def updateScheduleInformation(self, account, password, classroom):
     db = MysqlUse()
     sch = SchoolApiGet()
     i = 0
     schedule_data = sch.get_schedule_info(account, password)
     while 'schedule' not in schedule_data:
         res_schedule = sch.get_schedule_info(account, password)
         i = i + 1
         if i >= 4:
             return res_schedule
     if not schedule_data['schedule']:
         return {'isScore': 1}
     sel_schedule = {
         'classroom': classroom,
         'school_year': schedule_data['schedule_year'],
         'term': schedule_data['schedule_term'],
     }
     validate_schedule = db.validateSchedule(sel_schedule)
     if validate_schedule:
         return {'isSchedule': 1}
     else:
         for day in range(len(schedule_data['schedule'])):
             for lesson in range(len(schedule_data['schedule'][day])):
                 for x in range(len(schedule_data['schedule'][day][lesson])):
                     res_sql = db.insertSchedule(schedule_data['schedule_year'], schedule_data['schedule_term'], day,
                                                 lesson, classroom, schedule_data['schedule'][day][lesson][x])
                     if not res_sql:
                         return False
         sel_schedule = {
             'classroom': classroom,
             'school_year': schedule_data['schedule_year'],
             'term': schedule_data['schedule_term'],
         }
         res_select = db.validateSchedule(sel_schedule)
         if not res_select:
             return {'isSchedule': 1}
         else:
             return {'isSchedule': 0}