From 81ef3b36834da97dc8989ca99da9bf17b317f9d2 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 12 Nov 2012 23:13:32 +0100 Subject: [PATCH] Forgot this one into the previous commit :p see #333 --- modoboa/extensions/stats/grapher.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modoboa/extensions/stats/grapher.py b/modoboa/extensions/stats/grapher.py index 4da6ac8e4..6ca6ab407 100644 --- a/modoboa/extensions/stats/grapher.py +++ b/modoboa/extensions/stats/grapher.py @@ -31,23 +31,23 @@ class Grapher(object): self.rrd_rootdir = parameters.get_admin("RRD_ROOTDIR") self.img_rootdir = parameters.get_admin("IMG_ROOTDIR") - def process(self, target, suffix, start, end, tpl): + def process(self, target, suffix, start, end, graph_tpl): import rrdtool rrdfile = "%s/%s.rrd" % (self.rrd_rootdir, target) if not os.path.exists(rrdfile): return ext = "png" - path = "%s/%s_%s_%s_%s.%s" % (self.img_rootdir, tpl['name'], - target, tpl['cf'], suffix, ext) + path = "%s/%s_%s_%s_%s.%s" % (self.img_rootdir, graph_tpl.display_name, + target, graph_tpl.cf, suffix, ext) start = str(start) end = str(end) defs = [] lines = [] defs.append('COMMENT: %s %s %s %s\\c' % ("From", start, "to", end)) defs.append('COMMENT:\\s') - for v, d in tpl["vars"].iteritems(): - defs += [str('DEF:%s=%s:%s:%s' % (v, rrdfile, v, tpl['cf'])), + for v, d in graph_tpl.vars.iteritems(): + defs += [str('DEF:%s=%s:%s:%s' % (v, rrdfile, v, graph_tpl.cf)), str('CDEF:%spm=%s,60,*' % (v, v)), str('VDEF:%s_total=%s,TOTAL' % (v, v))] type = d.has_key("type") and d["type"] or "LINE" @@ -58,25 +58,25 @@ class Grapher(object): params = defs + lines rrdtool.graph(str(path), "--imgformat", "PNG", - "--width", tpl["width"], - "--height", tpl["height"], + "--width", str(graph_tpl.width), + "--height", str(graph_tpl.height), "--start", start, "--end", end, - "--vertical-label", tpl["vertlabel"].encode("utf-8"), + "--vertical-label", graph_tpl.vertlabel.encode("utf-8"), "--lower-limit", "0", "--slope-mode", "--units-exponent", "0", - "--title", tpl["title"].encode("utf-8"), + "--title", graph_tpl.title.encode("utf-8"), *params) if not os.path.exists(path): print "[graph] Impossible to create %s graph" %path - def make_defaults(self, target, tpl): + def make_defaults(self, target, graph_tpl): end = "%d" % int(time.mktime(time.localtime())) - self.process(target, "day", "-1day", end, tpl) - self.process(target, "week", "-1week", end, tpl) - self.process(target, "month", "-1month", end, tpl) - self.process(target, "year", "-1year", end, tpl) + self.process(target, "day", "-1day", end, graph_tpl) + self.process(target, "week", "-1week", end, graph_tpl) + self.process(target, "month", "-1month", end, graph_tpl) + self.process(target, "year", "-1year", end, graph_tpl)