diff --git a/judge/client.py b/judge/client.py index 37efa66..f57690b 100644 --- a/judge/client.py +++ b/judge/client.py @@ -209,7 +209,7 @@ class JudgeClient(object): -src = """ +c_src = """ #include int main() { @@ -217,14 +217,30 @@ int main() return 0; } """ -f = open("/var/judger/main.c", "w") -f.write(src) -f.close() -client = JudgeClient(language_code=1, - exe_path=compile_(languages["1"], "/var/judger/main.c", "/var/judger/main"), - max_cpu_time=1000000, - max_real_time=200000, - max_memory=1, - test_case_dir="/var/test_cases/1/") -print client.run() +java_src = """ +public class Main { + public static void main(String[] args) { + System.out.print("Hello world"); + } +} +""" +def judge(languege_code, source_string): + language = languages[str(languege_code)] + src_path = judger_workspace + language["src_name"] + f = open(src_path, "w") + f.write(source_string) + f.close() + + client = JudgeClient(language_code=languege_code, + exe_path=compile_(languages[str(languege_code)], + src_path, + judger_workspace), + max_cpu_time=1000000, + max_real_time=200000, + max_memory=1000, + test_case_dir="/var/test_cases/1/") + print client.run() + +judge(1, c_src) +judge(3, java_src) \ No newline at end of file diff --git a/judge/language.py b/judge/language.py index b596ee3..e59ef82 100644 --- a/judge/language.py +++ b/judge/language.py @@ -5,21 +5,24 @@ languages = { "1": { "name": "c", + "src_name": "main.c", "code": 1, - "compile_command": "gcc -DONLINE_JUDGE -O2 -Wall -std=c99 -pipe {src_path} -lm -o {exe_path}", - "execute_command": "{exe_path}" + "compile_command": "gcc -DONLINE_JUDGE -O2 -Wall -std=c99 -pipe {src_path} -lm -o {exe_path}main", + "execute_command": "{exe_path}main" }, "2": { "name": "cpp", + "src_name": "main.cpp", "code": 2, - "compile_command": "g++ -DONLINE_JUDGE -O2 -Wall -std=c++11 -pipe {src_path} -lm -o {exe_path}", - "execute_command": "{exe_path}" + "compile_command": "g++ -DONLINE_JUDGE -O2 -Wall -std=c++11 -pipe {src_path} -lm -o {exe_path}main", + "execute_command": "{exe_path}main" }, "3": { "name": "java", + "src_name": "Main.java", "code": 3, "compile_command": "javac {src_path} -d {exe_path}", - "execute_command": "java {exe_path}" + "execute_command": "java -cp {exe_path} Main" } }