summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6159b6f)
raw | patch | inline | side by side (parent: 6159b6f)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 5 Aug 2016 15:09:59 +0000 (17:09 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 5 Aug 2016 15:09:59 +0000 (17:09 +0200) |
Return an error when something goes wrong during config.
We still loop through all specified modules so all errors are logged.
Fixes #926
We still loop through all specified modules so all errors are logged.
Fixes #926
src/python.c | patch | blob | history |
diff --git a/src/python.c b/src/python.c
index f5b8b93de3369921410ec1de4fe296dd9f96e5ba..a14c06b01f82136ae96270ed00e057c63525bd14 100644 (file)
--- a/src/python.c
+++ b/src/python.c
static int cpy_config(oconfig_item_t *ci) {
PyObject *tb;
+ int status = 0;
/* Ok in theory we shouldn't do initialization at this point
* but we have to. In order to give python scripts a chance
tb = PyImport_ImportModule("traceback"); /* New reference. */
if (tb == NULL) {
cpy_log_exception("python initialization");
+ status = 1;
continue;
}
cpy_format_exception = PyObject_GetAttrString(tb, "format_exception"); /* New reference. */
Py_DECREF(tb);
- if (cpy_format_exception == NULL)
+ if (cpy_format_exception == NULL) {
cpy_log_exception("python initialization");
+ status = 1;
+ }
} else if (strcasecmp(item->key, "ModulePath") == 0) {
char *dir = NULL;
PyObject *dir_object;
"a python object.", dir);
free(dir);
cpy_log_exception("python initialization");
+ status = 1;
continue;
}
if (PyList_Insert(sys_path, 0, dir_object) != 0) {
ERROR("python plugin: Unable to prepend \"%s\" to "
"python module path.", dir);
cpy_log_exception("python initialization");
+ status = 1;
}
Py_DECREF(dir_object);
free(dir);
if (module == NULL) {
ERROR("python plugin: Error importing module \"%s\".", module_name);
cpy_log_exception("importing module");
+ status = 1;
}
free(module_name);
Py_XDECREF(module);
"a configuration callback.", name);
free(name);
continue;
+ status = 1;
}
free(name);
if (c->data == NULL)
else
ret = PyObject_CallFunction(c->callback, "NO",
cpy_oconfig_to_pyconfig(item, NULL), c->data); /* New reference. */
- if (ret == NULL)
+ if (ret == NULL) {
cpy_log_exception("loading module");
- else
+ status = 1;
+ } else
Py_DECREF(ret);
} else {
WARNING("python plugin: Ignoring unknown config key \"%s\".", item->key);
}
}
- return 0;
+ return (status);
}
void module_register(void) {