mirror of
https://github.com/QingdaoU/Judger.git
synced 2025-01-16 01:13:25 +00:00
add use_sandbox parameter
This commit is contained in:
parent
11ace673e2
commit
da1a446946
19
judger.c
19
judger.c
@ -7,15 +7,16 @@ static PyObject *error;
|
||||
|
||||
static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
struct config config;
|
||||
struct result result = {0, 0, 0, 0, 0};
|
||||
PyObject *args_list = NULL, *env_list = NULL, *next = NULL, *args_iter = NULL, *env_iter = NULL;
|
||||
struct result result = {0, 0, 0, 0, 0, 1};
|
||||
PyObject *args_list = NULL, *env_list = NULL, *use_sandbox, *next = NULL, *args_iter = NULL, *env_iter = NULL;
|
||||
int count = 0;
|
||||
static char *kwargs_list[] = {"path", "in_file", "out_file", "max_cpu_time", "max_memory", "args", "env", NULL};
|
||||
static char *kwargs_list[] = {"path", "in_file", "out_file", "max_cpu_time",
|
||||
"max_memory", "args", "env", "use_sandbox", NULL};
|
||||
|
||||
config.path = config.in_file = config.out_file = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssii|OO", kwargs_list, &(config.path), &(config.in_file),
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssii|OOO", kwargs_list, &(config.path), &(config.in_file),
|
||||
&(config.out_file), &(config.max_cpu_time), &(config.max_memory),
|
||||
&args_list, &env_list)) {
|
||||
&args_list, &env_list, &use_sandbox)) {
|
||||
PyErr_SetString(error, "Invalid args and kwargs");
|
||||
return NULL;
|
||||
}
|
||||
@ -79,6 +80,14 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
}
|
||||
config.env[count] = NULL;
|
||||
|
||||
if (use_sandbox != NULL) {
|
||||
if (!PyBool_Check(use_sandbox)) {
|
||||
PyErr_SetString(error, "use sandbox must ba a bool");
|
||||
return NULL;
|
||||
}
|
||||
config.use_sandbox = PyObject_IsTrue(use_sandbox);
|
||||
}
|
||||
|
||||
run(&config, &result);
|
||||
return Py_BuildValue("{s:i, s:l, s:i, s:i, s:i, s:i}",
|
||||
"cpu_time", result.cpu_time, "memory", result.memory, "real_time", result.real_time, "signal",
|
||||
|
Loading…
x
Reference in New Issue
Block a user