apcups plugin: Handle "END APC" lines correctly and stop reading.
[collectd.git] / src / python.c
index 8bcf82c..d2ef164 100644 (file)
@@ -656,7 +656,6 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
        double interval = 0;
        char *name = NULL;
        PyObject *callback = NULL, *data = NULL;
-       struct timespec ts;
        static char *kwlist[] = {"callback", "interval", "data", "name", NULL};
        
        if (PyArg_ParseTupleAndKeywords(args, kwds, "O|dOet", kwlist, &callback, &interval, &data, NULL, &name) == 0) return NULL;
@@ -678,10 +677,8 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
        user_data = malloc(sizeof(*user_data));
        user_data->free_func = cpy_destroy_user_data;
        user_data->data = c;
-       ts.tv_sec = interval;
-       ts.tv_nsec = (interval - ts.tv_sec) * 1000000000;
        plugin_register_complex_read(/* group = */ NULL, buf,
-                       cpy_read_callback, &ts, user_data);
+                       cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), user_data);
        return cpy_string_to_unicode_or_bytes(buf);
 }
 
@@ -1159,8 +1156,8 @@ static int cpy_config(oconfig_item_t *ci) {
                                cpy_log_exception("python initialization");
                                continue;
                        }
-                       if (PyList_Append(sys_path, dir_object) != 0) {
-                               ERROR("python plugin: Unable to append \"%s\" to "
+                       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");
                        }