|
|
@@ -2,7 +2,6 @@
|
|
|
import os
|
|
|
import random
|
|
|
import shutil
|
|
|
-import time
|
|
|
|
|
|
from flask import Flask, request, json
|
|
|
import judgement
|
|
|
@@ -29,7 +28,6 @@ inputOutputMapping: hashmap 输入输出对
|
|
|
|
|
|
@app.route('/api/judge', methods=['POST'])
|
|
|
def judge():
|
|
|
- start = time.time()
|
|
|
requestData = request.get_data(as_text=True)
|
|
|
data = json.loads(requestData)
|
|
|
code = data['code']
|
|
|
@@ -38,10 +36,7 @@ def judge():
|
|
|
memory_limit = int(data['memoryLimit'])
|
|
|
input_list = data['inputList']
|
|
|
output_list = data['outputList']
|
|
|
-
|
|
|
app_path = os.getcwd()
|
|
|
- app.logger.info(app_path)
|
|
|
-
|
|
|
rand = int(random.random() * 10000000)
|
|
|
dir_name = 'commit-' + str(rand)
|
|
|
while os.path.exists(dir_name):
|
|
|
@@ -49,7 +44,6 @@ def judge():
|
|
|
dir_name = 'commit-' + str(rand)
|
|
|
os.mkdir(dir_name)
|
|
|
os.chdir(app_path+'/'+dir_name)
|
|
|
- app.logger.info(os.getcwd())
|
|
|
|
|
|
if len(input_list) != len(output_list):
|
|
|
return {"result_list": [{'result': "System Error"}],
|
|
|
@@ -58,12 +52,8 @@ def judge():
|
|
|
save_test_cases(input_list, output_list, td_total)
|
|
|
src_file = save_code(language, code)
|
|
|
rst = judgement.judge(src_file, 'testcases', td_total, time_limit, memory_limit, language)
|
|
|
- os.remove(src_file)
|
|
|
- shutil.rmtree('testcases')
|
|
|
os.chdir(app_path)
|
|
|
- app.logger.info(os.getcwd())
|
|
|
shutil.rmtree(dir_name)
|
|
|
- app.logger.info(time.time() - start)
|
|
|
return rst
|
|
|
|
|
|
|