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;
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);
}
#endif
static int cpy_init_python() {
- char *argv = "";
PyObject *sys;
PyObject *module;
#ifdef IS_PY3K
+ wchar_t *argv = L"";
/* Add a builtin module, before Py_Initialize */
PyImport_AppendInittab("collectd", PyInit_collectd);
+#else
+ char *argv = "";
#endif
Py_Initialize();
} else if (strcasecmp(item->key, "Encoding") == 0) {
if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_STRING)
continue;
+#ifdef IS_PY3K
+ NOTICE("python: \"Encoding\" was used in the config file but Python3 was used, which does not support changing encodings. Ignoring this.");
+#else
/* Why is this even necessary? And undocumented? */
if (PyUnicode_SetDefaultEncoding(item->values[0].value.string))
cpy_log_exception("setting default encoding");
+#endif
} else if (strcasecmp(item->key, "LogTraces") == 0) {
if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN)
continue;