def login_handler(self, data): id = data.split(";")[2].split(",")[0] password = data.split(";")[2].split(",")[1] courses = '' if len(password) != 0: try: masterInfo = select_master_check(id) idIndex = masterInfo.index if check_password_hash(masterInfo.password, TripleDES.encrypt(str(password))) is False: self.request.send('0'.encode('utf-8')) return except: self.request.send('0'.encode('utf-8')) return try: courseList = select_unfinished_test_course_for_master(idIndex) for courseInfo in courseList: userCount = select_user_count(courseInfo.index) banList = select_ban_list_index(courseInfo.index) allowList = select_allow_list_index(courseInfo.index) banList = str(banList).strip('[]').replace(' ','').replace('(','').replace(',)','').replace(',','*') allowList = str(allowList).strip('[]').replace(' ','').replace('(','').replace(',)','').replace(',','*') courseData = courseInfo.testName + "," + str(courseInfo.startDate) + "," + str(courseInfo.endDate) + "," + banList + "," + allowList + "," + str(userCount) courses = courses + '^' + courseData except: courses = '' courses = courses.lstrip('^') else: try: idIndex = select_user_index(id) except: self.request.send('0'.encode('utf-8')) return try: courseList = select_unfinished_test_course_for_user(idIndex) if len(courseList) is 0: self.request.send('-1'.encode('utf-8')) return courses = str(courseList).strip('[]').replace(' ','').replace('(','').replace(',)','').replace("'", '') except: self.request.send('-1'.encode('utf-8')) return sendData = str(idIndex)+"^"+courses self.request.send(sendData.encode('utf-8'))
def select_course(self, data): courseName = data.split(";")[2] sendData = '' courseIndex = select_course_index(courseName) endDate = get_course_end_date(courseIndex) siteIndexList = select_allow_list_index(courseIndex) siteIndexList = str(siteIndexList).strip('[]').replace(' ','').replace('(','').replace(',)','').replace(',', '*') programIndexList = select_ban_list_index(courseIndex) programIndexList = str(programIndexList).strip('[]').replace(' ','').replace('(','').replace(',)','').replace(',', '*') sendData = programIndexList+","+siteIndexList+","+str(endDate) self.request.send(sendData.encode('utf-8'))