示例#1
0
    def get_judge_dict_by_problem_id(
            self, problem_id_str):  #This function is call by judge client
        if self.connection.exists(problem_id_str):
            record_string_in_redis = self.connection.get(problem_id_str)

            problem_record = ProblemRecored()
            problem_record.fromString(record_string_in_redis)
            judge_dict = problem_record.getJudge()
            return judge_dict
        else:
            logger.error(
                'Problem \"{}\" not exist when call judgeclient_view.get_judge_dict_by_problem_id() !'
                .format(problem_id_str))
            raise MessageException('The problem is not exist !')
示例#2
0
    def get_problem_judge_and_result_status(
        self, problem_id_str, secret
    ):  #web client use this to get the judge status of a given problem
        if self.connection.exists(problem_id_str):
            record_string_in_redis = self.connection.get(problem_id_str)

            problem_record = ProblemRecored()
            problem_record.fromString(record_string_in_redis)
            problem_judge = problem_record.getJudge()

            problem_secret = problem_judge["secret"]
            if secret != problem_secret:
                raise MessageException('Secret not match with is problem !')
            else:
                problem_record.data.pop(
                    'problem')  #return the ProblemRecord without problem field
                return problem_record.data
        else:
            self._remove_problem_from_queue_by_problem_id(problem_id_str)
            logger.error(
                'Problem \"{}\" not exist , delete from waiting and judging queue !'
                .format(problem_id_str))
            raise MessageException('The problem is not exist !')