]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Add dump support to Python bindings. 388/head
authorSteve Dougherty <steve@asksteved.com>
Wed, 8 May 2013 04:42:27 +0000 (00:42 -0400)
committerSteve Dougherty <steve@asksteved.com>
Wed, 8 May 2013 04:42:27 +0000 (00:42 -0400)
bindings/python/rrdtoolmodule.c

index 54855e6b28103996c734292d114edf8903c7cdd3..502b70c6ccf27d9537b21a845d906b776467b866 100644 (file)
@@ -665,6 +665,34 @@ static PyObject *PyRRD_xport(
     return r;
 }
 
+static char PyRRD_dump__doc__[] =
+    "dump - dump an RRD to XML\n"
+    "[--header|-h {none,xsd,dtd}] [--no-header]file.rrd [file.xml]";
+
+static PyObject *PyRRD_dump(
+    PyObject UNUSED(*self),
+    PyObject * args)
+{
+    PyObject *r;
+    int       argc;
+    char    **argv;
+
+    if (create_args("dump", args, &argc, &argv) < 0)
+        return NULL;
+
+    if (rrd_dump(argc, argv) != 0) {
+        PyErr_SetString(ErrorObject, rrd_get_error());
+        rrd_clear_error();
+        r = NULL;
+    } else {
+        Py_INCREF(Py_None);
+        r = Py_None;
+    }
+
+    destroy_args(&argv);
+    return r;
+}
+
 /* List of methods defined in the module */
 #define meth(name, func, doc) {name, (PyCFunction)func, METH_VARARGS, doc}
 
@@ -682,6 +710,7 @@ static PyMethodDef _rrdtool_methods[] = {
     meth("updatev", PyRRD_updatev, PyRRD_updatev__doc__),
     meth("flushcached", PyRRD_flushcached, PyRRD_flushcached__doc__),
     meth("xport", PyRRD_xport, PyRRD_xport__doc__),
+    meth("dump", PyRRD_dump, PyRRD_dump__doc__),
     {NULL, NULL, 0, NULL}
 };