Explorar el Código

修改接口返回信息

blumonilr hace 5 años
padre
commit
5c10611fde
Se han modificado 1 ficheros con 7 adiciones y 6 borrados
  1. 7 6
      web/judgement.py

+ 7 - 6
web/judgement.py

@@ -75,22 +75,22 @@ def judge(src_path, td_path, td_total, time_limit, memory_limit, language):
     rst_list = []
     if language == 'c':
         if not compile_c(src_path):
-            return {'result': RESULT_STR[7]}
+            return {'result_list': [{'result': RESULT_STR[7]}]}
         args = ['./main']
         src_file = 'main'
     elif language == 'cpp':
         if not compile_cpp(src_path):
-            return {'result': RESULT_STR[7]}
+            return {'result_list': [{'result': RESULT_STR[7]}]}
         args = ['./main']
         src_file = 'main'
     elif language == 'java':
         if not compile_java(src_path):
-            return {'result': RESULT_STR[7]}
+            return {'result_list': [{'result': RESULT_STR[7]}]}
         args = ['java', 'Main']
         src_file = 'Main.class'
     elif language == 'python':
         if not compile_python(src_path):
-            return {'result': RESULT_STR[7]}
+            return {'result_list': [{'result': RESULT_STR[7]}]}
         args = ['python3', 'main.py']
         src_file = 'main.pyc'
     for i in range(td_total):
@@ -102,7 +102,8 @@ def judge(src_path, td_path, td_total, time_limit, memory_limit, language):
             rst_list.append(rst)
         else:
             os.remove(src_file)
-            return {'result': RESULT_STR[8],
+            rst_list.append({'result': RESULT_STR[8]})
+            return {'result_list': rst_list,
                     'message': 'test data:%d incompleted' % i}
     os.remove(src_file)
-    return rst_list
+    return {'result_list': rst_list}