添加重新判题的脚本,可以有选择地重判一部分提交,并生成新的提交,可指定用户~[CI SKIP]
This commit is contained in:
74
Accessories/reJudge.py
Normal file
74
Accessories/reJudge.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import django
|
||||
from contest.models import *
|
||||
from problem.models import *
|
||||
from submission.models import Submission
|
||||
|
||||
import redis
|
||||
|
||||
from judge.judger_controller.tasks import judge
|
||||
from judge.judger_controller.settings import redis_config
|
||||
|
||||
django.setup()
|
||||
|
||||
|
||||
def rejudge(submission):
|
||||
# for submission in submission:
|
||||
# submission_id = submission.id
|
||||
# try:
|
||||
# command = "%s run -t -i --privileged --rm=true " \
|
||||
# "-v %s:/var/judger/test_case/ " \
|
||||
# "-v %s:/var/judger/code/ " \
|
||||
# "%s " \
|
||||
# "python judge/judger/run.py " \
|
||||
# "--solution_id %s --time_limit %s --memory_limit %s --test_case_id %s" % \
|
||||
# (docker_config["docker_path"],
|
||||
# test_case_dir,
|
||||
# source_code_dir,
|
||||
# docker_config["image_name"],
|
||||
# submission_id, str(time_limit), str(memory_limit), test_case_id)
|
||||
# subprocess.call(command, shell=docker_config["shell"])
|
||||
# except Exception as e:
|
||||
# print e
|
||||
return
|
||||
|
||||
|
||||
def easy_rejudge(submissions, map_table, user_id, contest_id=None):
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
except User.DoesNotExist:
|
||||
print "User.DoesNotExist!"
|
||||
return
|
||||
problemDict = {}
|
||||
for oldSubmission in submission:
|
||||
problem_id = map_table[oldSubmission.problem_id]
|
||||
|
||||
if problem_id in problemDict:
|
||||
problem = problemDict[problem_id]
|
||||
else:
|
||||
try:
|
||||
p = Problem.objects.get(pk=problem_id)
|
||||
except Problem.DoesNotExist:
|
||||
print " Problem.DoesNotExist!" + str(problem_id)
|
||||
continue
|
||||
problem = p
|
||||
problemDict[problem_id] = p
|
||||
|
||||
submission = Submission.objects.create(
|
||||
user_id=user_id,
|
||||
language=oldSubmission.language,
|
||||
code=oldSubmission.code,
|
||||
contest_id=contest_id,
|
||||
problem_id=problem_id,
|
||||
originResult=oldSubmission.result
|
||||
)
|
||||
try:
|
||||
judge.delay(submission.id, problem.time_limit, problem.memory_limit, problem.test_case_id)
|
||||
except Exception:
|
||||
print "提交判题任务失败"
|
||||
continue
|
||||
# 增加redis 中判题队列长度的计数器
|
||||
r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
||||
r.incr("judge_queue_length")
|
||||
|
||||
return
|
||||
|
||||
@@ -14,6 +14,7 @@ def add_exist_problem_to_contest(problems, contest_id):
|
||||
for problem in problems:
|
||||
print "Add the problem:"
|
||||
print problem.title
|
||||
print "The sort Index is" + str(i) + " You Can modify it latter as you like~"
|
||||
ContestProblem.objects.create(contest=contest, sort_index=str(i),
|
||||
title=problem.title, description=problem.description,
|
||||
input_description=problem.input_description,
|
||||
@@ -24,4 +25,5 @@ def add_exist_problem_to_contest(problems, contest_id):
|
||||
created_by=problem.created_by,
|
||||
time_limit=problem.time_limit,
|
||||
memory_limit=problem.memory_limit)
|
||||
i += 1
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user