From: oetiker Date: Fri, 7 Jul 2006 22:37:20 +0000 (+0000) Subject: added first function to python bindings ... -- Ulf Lilleengen lulf pvv.ntnu.no X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3a636497643818c549bf909e781f0251579615e6;p=rrdtool-all.git added first function to python bindings ... -- Ulf Lilleengen lulf pvv.ntnu.no git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@851 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/CONTRIBUTORS b/program/CONTRIBUTORS index 8a47341e..aaf7718d 100644 --- a/program/CONTRIBUTORS +++ b/program/CONTRIBUTORS @@ -61,6 +61,7 @@ Tobias Weingartner Tom Crawley (GCC&HP configuration) Travis Brown Tuc +Ulf Lilleengen Python binding for 'rrdtool first' Ulrich Schilling AIX Wim Heirman --units=si option Wolfgang Schrimm xport function diff --git a/program/bindings/python/rrdtoolmodule.c b/program/bindings/python/rrdtoolmodule.c index f5a96d95..a0061040 100644 --- a/program/bindings/python/rrdtoolmodule.c +++ b/program/bindings/python/rrdtoolmodule.c @@ -313,6 +313,30 @@ PyRRD_tune(PyObject UNUSED(*self), PyObject *args) return r; } +static char PyRRD_first__doc__[] = +"first(filename): Return the timestamp of the first data sample in an RRD"; + +static PyObject * +PyRRD_first(PyObject UNUSED(*self), PyObject *args) +{ + PyObject *r; + int argc, ts; + char **argv; + + if (create_args("first", args, &argc, &argv) < 0) + return NULL; + + if ((ts = rrd_first(argc, argv)) == -1) { + PyErr_SetString(ErrorObject, rrd_get_error()); + rrd_clear_error(); + r = NULL; + } else + r = PyInt_FromLong((long)ts); + + destroy_args(&argv); + return r; +} + static char PyRRD_last__doc__[] = "last(filename): Return the timestamp of the last data sample in an RRD"; @@ -476,6 +500,7 @@ static PyMethodDef _rrdtool_methods[] = { meth("fetch", PyRRD_fetch, PyRRD_fetch__doc__), meth("graph", PyRRD_graph, PyRRD_graph__doc__), meth("tune", PyRRD_tune, PyRRD_tune__doc__), + meth("first", PyRRD_first, PyRRD_first__doc__), meth("last", PyRRD_last, PyRRD_last__doc__), meth("resize", PyRRD_resize, PyRRD_resize__doc__), meth("info", PyRRD_info, PyRRD_info__doc__),