From f9c4356683c228d8e2fc1716e5db78160347acd8 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 29 Oct 2015 17:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E7=85=A7=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=20id=20=E6=9F=A5=E8=AF=A2=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E8=AF=A6=E6=83=85=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problem/views.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/problem/views.py b/problem/views.py index e48b8a5..88cf4e7 100644 --- a/problem/views.py +++ b/problem/views.py @@ -248,17 +248,31 @@ class TestCaseUploadAPIView(APIView): "output_name": str(i + 1) + ".out", "output_md5": md5.hexdigest(), "striped_output_md5": striped_md5.hexdigest(), + "input_size": os.path.getsize(test_case_dir + str(i + 1) + ".in"), "output_size": os.path.getsize(test_case_dir + str(i + 1) + ".out")} # 写入配置文件 with open(test_case_dir + "info", "w") as f: f.write(json.dumps(file_info)) return success_response({"test_case_id": problem_test_dir, - "file_list": {"input": l[0::2], - "output": l[1::2]}}) + "file_list": file_info["test_cases"]}) else: return error_response(u"测试用例压缩文件格式错误,请保证测试用例文件在根目录下直接压缩") + def get(self, request): + test_case_id = request.GET.get("test_case_id", None) + if not test_case_id: + return error_response(u"参数错误") + test_case_config = settings.TEST_CASE_DIR + test_case_id + "/info" + try: + f = open(test_case_config) + config = json.loads(f.read()) + f.close() + except Exception as e: + return error_response(u"读取测试用例出错") + return success_response({"file_list": config["test_cases"]}) + + def problem_list_page(request, page=1): """