mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2025-11-04 14:50:01 +08:00
python3 client
This commit is contained in:
parent
a1eb1628ee
commit
920b931681
@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals, print_function
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
@ -16,7 +16,7 @@ class JudgeServerClientError(Exception):
|
|||||||
|
|
||||||
class JudgeServerClient(object):
|
class JudgeServerClient(object):
|
||||||
def __init__(self, token, server_base_url):
|
def __init__(self, token, server_base_url):
|
||||||
self.token = hashlib.sha256(token).hexdigest()
|
self.token = hashlib.sha256(token.encode("utf-8")).hexdigest()
|
||||||
self.server_base_url = server_base_url.rstrip("/")
|
self.server_base_url = server_base_url.rstrip("/")
|
||||||
|
|
||||||
def _request(self, url, data=None):
|
def _request(self, url, data=None):
|
||||||
@ -53,7 +53,7 @@ class JudgeServerClient(object):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
token = hashlib.sha256("token").hexdigest()
|
token = "123456"
|
||||||
|
|
||||||
c_src = r"""
|
c_src = r"""
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -102,30 +102,30 @@ if __name__ == "__main__":
|
|||||||
s1 = s.split(" ")
|
s1 = s.split(" ")
|
||||||
print int(s1[0]) + int(s1[1])"""
|
print int(s1[0]) + int(s1[1])"""
|
||||||
|
|
||||||
client = JudgeServerClient(token="token", server_base_url="http://123.57.151.42:12358")
|
client = JudgeServerClient(token=token, server_base_url="http://test.qduoj.com:12358")
|
||||||
print client.ping(), "\n\n"
|
print(client.ping(), "\n\n")
|
||||||
|
|
||||||
print client.compile_spj(src=c_spj_src, spj_version="2", spj_compile_config=c_lang_spj_compile,
|
print(client.compile_spj(src=c_spj_src, spj_version="2", spj_compile_config=c_lang_spj_compile,
|
||||||
test_case_id="spj"), "\n\n"
|
test_case_id="spj"), "\n\n")
|
||||||
|
|
||||||
print client.judge(src=c_src, language_config=c_lang_config,
|
print(client.judge(src=c_src, language_config=c_lang_config,
|
||||||
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
||||||
test_case_id="normal", output=True), "\n\n"
|
test_case_id="normal", output=True), "\n\n")
|
||||||
|
|
||||||
print client.judge(src=cpp_src, language_config=cpp_lang_config,
|
print(client.judge(src=cpp_src, language_config=cpp_lang_config,
|
||||||
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
||||||
test_case_id="normal"), "\n\n"
|
test_case_id="normal"), "\n\n")
|
||||||
|
|
||||||
print client.judge(src=java_src, language_config=java_lang_config,
|
print(client.judge(src=java_src, language_config=java_lang_config,
|
||||||
max_cpu_time=1000, max_memory=1024 * 1024 * 1024,
|
max_cpu_time=1000, max_memory=1024 * 1024 * 1024,
|
||||||
test_case_id="normal"), "\n\n"
|
test_case_id="normal"), "\n\n")
|
||||||
|
|
||||||
print client.judge(src=c_src, language_config=c_lang_config,
|
print(client.judge(src=c_src, language_config=c_lang_config,
|
||||||
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
max_cpu_time=1000, max_memory=1024 * 1024 * 128,
|
||||||
test_case_id="spj",
|
test_case_id="spj",
|
||||||
spj_version="3", spj_config=c_lang_spj_config,
|
spj_version="3", spj_config=c_lang_spj_config,
|
||||||
spj_compile_config=c_lang_spj_compile, spj_src=c_spj_src), "\n\n"
|
spj_compile_config=c_lang_spj_compile, spj_src=c_spj_src), "\n\n")
|
||||||
|
|
||||||
print client.judge(src=py2_src, language_config=py2_lang_config,
|
print(client.judge(src=py2_src, language_config=py2_lang_config,
|
||||||
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
max_cpu_time=1000, max_memory=128 * 1024 * 1024,
|
||||||
test_case_id="normal"), "\n\n"
|
test_case_id="normal"), "\n\n")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user