X-Git-Url: http://git.ipfire.org/?p=collecty.git;a=blobdiff_plain;f=src%2Fcollecty%2Fplugins%2Fbase.py;h=ca98ef721df25085098e1a744e2b860a15d8cd18;hp=c9e815c52d48ebd831af1a5a05f188adc0473df9;hb=a386481247af3ce6f554162a4c3632afe2513b89;hpb=ac5bd9d3d9316d73458b57bebf73b3a57b7e4182 diff --git a/src/collecty/plugins/base.py b/src/collecty/plugins/base.py index c9e815c..ca98ef7 100644 --- a/src/collecty/plugins/base.py +++ b/src/collecty/plugins/base.py @@ -255,6 +255,15 @@ class Plugin(object, metaclass=PluginRegistration): return graph + def graph_info(self, template_name, object_id="default", + timezone=None, locale=None, **kwargs): + template = self.get_template(template_name, object_id=object_id, + timezone=timezone, locale=locale) + if not template: + raise RuntimeError("Could not find template %s" % template_name) + + return template.graph_info() + class Object(object): # The schema of the RRD database. @@ -550,4 +559,19 @@ class GraphTemplate(object): with Environment(self.timezone, self.locale.lang): graph = rrdtool.graphv("-", *args) - return graph.get("image") + return { + "image" : graph.get("image"), + "image_height" : graph.get("image_height"), + "image_width" : graph.get("image_width"), + } + + def graph_info(self): + """ + Returns a dictionary with useful information + about this graph. + """ + return { + "title" : self.graph_title, + "object_id" : self.object_id or "", + "template" : self.name, + }