delete debug script
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
__author__ = 'root'
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
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 "error!"
|
|
||||||
continue
|
|
||||||
|
|
||||||
r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
|
||||||
r.incr("judge_queue_length")
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import django
|
|
||||||
from contest.models import *
|
|
||||||
from problem.models import *
|
|
||||||
django.setup()
|
|
||||||
def add_exist_problem_to_contest(problems, contest_id):
|
|
||||||
try:
|
|
||||||
contest = Contest.objects.get(pk=contest_id)
|
|
||||||
except Contest.DoesNotExist:
|
|
||||||
print "Contest Doesn't Exist!"
|
|
||||||
return
|
|
||||||
i = 1
|
|
||||||
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,
|
|
||||||
output_description=problem.output_description,
|
|
||||||
samples=problem.samples,
|
|
||||||
test_case_id=problem.test_case_id,
|
|
||||||
hint=problem.hint,
|
|
||||||
created_by=problem.created_by,
|
|
||||||
time_limit=problem.time_limit,
|
|
||||||
memory_limit=problem.memory_limit)
|
|
||||||
i += 1
|
|
||||||
return
|
|
||||||
def add_contest_problem_to_problem(contest_id):
|
|
||||||
try:
|
|
||||||
contest = Contest.objects.get(pk=contest_id)
|
|
||||||
except Contest.DoesNotExist:
|
|
||||||
print "Contest Doesn't Exist!"
|
|
||||||
return
|
|
||||||
#Get all problems in this contest
|
|
||||||
problems = ContestProblem.objects.filter(contest=contest)
|
|
||||||
|
|
||||||
#get a tag
|
|
||||||
try:
|
|
||||||
tag = ProblemTag.objects.get(name=contest.title)
|
|
||||||
except ProblemTag.DoesNotExist:
|
|
||||||
tag = ProblemTag.objects.create(name=contest.title)
|
|
||||||
|
|
||||||
#for each problem
|
|
||||||
for problem in problems:
|
|
||||||
print "Add problem to problem list:"
|
|
||||||
print problem.title
|
|
||||||
p = Problem.objects.create(title=problem.title,
|
|
||||||
description=problem.description,
|
|
||||||
input_description=problem.input_description,
|
|
||||||
output_description=problem.output_description,
|
|
||||||
samples=problem.samples,
|
|
||||||
test_case_id=problem.test_case_id,
|
|
||||||
hint=problem.hint,
|
|
||||||
created_by=problem.created_by,
|
|
||||||
time_limit=problem.time_limit,
|
|
||||||
memory_limit=problem.memory_limit,
|
|
||||||
visible = False,
|
|
||||||
difficulty = 0,
|
|
||||||
source = contest.title)
|
|
||||||
p.tags.add(tag)
|
|
||||||
return
|
|
||||||
Reference in New Issue
Block a user