pvl.rrd: api.report()
authorTero Marttila <terom@paivola.fi>
Thu, 16 May 2013 01:01:42 +0300
changeset 232 5894c70dc6a8
parent 231 027a965a630d
child 233 c4941645464c
pvl.rrd: api.report()
.hgignore
pvl/rrd/api.py
pvl/rrd/graph.py
--- a/.hgignore	Wed May 01 00:24:35 2013 +0300
+++ b/.hgignore	Thu May 16 01:01:42 2013 +0300
@@ -10,4 +10,4 @@
 ^log
 
 # testing
-^(tmp|test|var)/
+^(tmp|test|var|opt)/
--- a/pvl/rrd/api.py	Wed May 01 00:24:35 2013 +0300
+++ b/pvl/rrd/api.py	Thu May 16 01:01:42 2013 +0300
@@ -87,6 +87,18 @@
             
     return (width, height), out_lines, out_file
 
+def report (*defs, **opts) :
+    """
+        Render an output-less graph with only PRINT statements as a textual report.
+
+        Returns output lines.
+    """
+    
+    # exec
+    width, height, out_lines = cmd(rrdtool.graph, ('/dev/null', ), opts, defs)
+
+    return out_lines
+
 def fetch (rrd, cf, **opts) :
     """
         Fetch values from RRD.
--- a/pvl/rrd/graph.py	Wed May 01 00:24:35 2013 +0300
+++ b/pvl/rrd/graph.py	Thu May 16 01:01:42 2013 +0300
@@ -55,7 +55,6 @@
                 args    = ', '.join([repr(def_) for def_ in self.defs] + [str(opt) + '=' + repr(value) for opt, value in self.opts.iteritems()]),
         )
 
-    # builders
 class Interface (Graph) :
     """
         An RRD graph showing in/out traffic in bits/s on an interface, with style/interval support.