From 699e99fb2b79584279fac170f7926165f09495fc Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 27 May 2015 23:07:55 +0000 Subject: [PATCH] Generate graphs in memory Remove Python 2 hack that created a temporary file on disk in which the graph was written and then read the file content back in. The Python 3 module allows us to write the graph directly into a buffer. --- src/collecty/plugins/base.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/collecty/plugins/base.py b/src/collecty/plugins/base.py index 476c134..004b2a1 100644 --- a/src/collecty/plugins/base.py +++ b/src/collecty/plugins/base.py @@ -483,17 +483,9 @@ class GraphTemplate(object): self.log.debug(" %s" % args[-1]) - return self.write_graph(*args) - - def write_graph(self, *args): - # Convert all arguments to string + # Convert arguments to string args = [str(e) for e in args] - with tempfile.NamedTemporaryFile() as f: - rrdtool.graph(f.name, *args) - - # Get back to the beginning of the file - f.seek(0) + graph = rrdtool.graphv("-", *args) - # Return all the content - return f.read() + return graph.get("image") -- 2.47.2