mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2024-12-28 21:31:43 +00:00
增加Java和c++相关配置
This commit is contained in:
parent
9779be6f40
commit
18a41e089b
63
client.py
63
client.py
@ -29,13 +29,32 @@ c_lang_config = {
|
||||
"max_cpu_time": 10000,
|
||||
"max_real_time": 20000,
|
||||
"max_memory": 1024 * 1024 * 1024,
|
||||
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 -static {src_path} -lm -o {exe_path}",
|
||||
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}",
|
||||
# server should replace to real info
|
||||
"version": "1",
|
||||
"src": ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cpp_lang_config = {
|
||||
"name": "cpp",
|
||||
"compile": {
|
||||
"src_name": "main.cpp",
|
||||
"exe_name": "main",
|
||||
"max_cpu_time": 3000,
|
||||
"max_real_time": 5000,
|
||||
"max_memory": 128 * 1024 * 1024,
|
||||
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++11 {src_path} -lm -o {exe_path}",
|
||||
},
|
||||
"run": {
|
||||
"command": "{exe_path}",
|
||||
"seccomp_rule": "c_cpp",
|
||||
"max_process_number": 5
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
java_lang_config = {
|
||||
"name": "java",
|
||||
"compile": {
|
||||
@ -47,7 +66,7 @@ java_lang_config = {
|
||||
"compile_command": "/usr/bin/javac {src_path} -d {exe_dir} -encoding UTF8"
|
||||
},
|
||||
"run": {
|
||||
"command": "/usr/bin/java -cp {exe_dir} -Xss1M -XX:MaxPermSize=16M -XX:PermSize=8M -Xms16M -Xmx{max_memory}k -Djava.awt.headless=true Main",
|
||||
"command": "/usr/bin/java -cp {exe_dir} -Xss1M -XX:MaxPermSize=16M -XX:PermSize=8M -Xms16M -Xmx{max_memory}k -Djava.security.manager -Djava.security.policy==/server/java_policy -Djava.awt.headless=true Main",
|
||||
"seccomp_rule": None,
|
||||
"max_process_number": -1
|
||||
}
|
||||
@ -62,11 +81,49 @@ c_config["spj_compile"]["src"] = "#include<stdio.h>\nint main(){//哈哈哈哈\n
|
||||
token = hashlib.sha256("token").hexdigest()
|
||||
|
||||
|
||||
c_src = r"""
|
||||
#include <stdio.h>
|
||||
int main(){
|
||||
int a, b;
|
||||
scanf("%d%d", &a, &b);
|
||||
printf("%d\n", a+b);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
cpp_src = r"""
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
while(1);
|
||||
cin >> a >> b;
|
||||
cout << a+b << endl;
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
java_src = r"""
|
||||
import java.util.Scanner;
|
||||
public class Main{
|
||||
public static void main(String[] args){
|
||||
Scanner in=new Scanner(System.in);
|
||||
int a=in.nextInt();
|
||||
int b=in.nextInt();
|
||||
System.out.println((a / (b - 2)));
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def judge():
|
||||
data = make_signature(token=token,
|
||||
language_config=java_lang_config,
|
||||
submission_id=submission_id,
|
||||
src="\nimport java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner in=new Scanner(System.in);\n int a=in.nextInt();\n int b=in.nextInt();\n System.out.println((a+b)); \n }\n}",
|
||||
src=java_src,
|
||||
max_cpu_time=1000, max_memory=1024 * 1024 * 1024,
|
||||
test_case_id="d28280c6f3c5ddeadfecc3956a52da3a")
|
||||
r = requests.post("http://192.168.99.100:8080/judge", data=json.dumps(data))
|
||||
|
3
java_policy
Normal file
3
java_policy
Normal file
@ -0,0 +1,3 @@
|
||||
grant {
|
||||
permission java.io.FilePermission "/tmp", "read";
|
||||
};
|
@ -132,12 +132,12 @@ urls = (
|
||||
"/ping", "JudgeServer"
|
||||
)
|
||||
|
||||
if not os.environ.get("judger_token"):
|
||||
raise SignatureVerificationFailed("token not set")
|
||||
|
||||
app = web.application(urls, globals())
|
||||
wsgiapp = app.wsgifunc()
|
||||
|
||||
# gunicorn -w 4 -b 0.0.0.0:8080 server:wsgiapp
|
||||
if __name__ == "__main__":
|
||||
if not os.environ.get("judger_token"):
|
||||
print "judger_token not set"
|
||||
exit(-1)
|
||||
app.run()
|
Loading…
Reference in New Issue
Block a user