[rrd-users] display graphs generated with python bindings in html
Clemens Weninger
clemens_weninger at gmx.net
Tue Dec 15 15:25:35 CET 2009
On Tuesday 15 December 2009 12:35:49 Michael P. Soulier wrote:
> On 15/12/09 Clemens Weninger said:
> > Hi,
> > ok thanks for that tip, I can easily modify the headers now. But a
> > problem that remains is how to get the image in the buffer?
> > I would like to call:
> >
> > #!/usr/bin/python
> > import rrdtool
> >
> > rrdtool.graph('-', <further options>) # that should go into buffer
> >
> > response = HttpResponse(mimetype="image/jpg")
> > response.write(buffer)
> > return response
> >
> > but that goes directly to stdout. I tried to redirect stdout to a buffer
> > but I couldn't get it to work.
>
> Can you pass the option an alternate file object? If so pass it a cStringIO
> object.
>
> Mike
>
Hi,
oh that is a good idea. Did you mean something like this?
img = cStringIO.StringIO()
rrdtool.graph(img, <other options>)
but that doesn't work. I get the error:
TypeError: argument 0 must be string or list of strings
So i must find a way to redirect the stdout if that is even possible in this
case.
thanks for your help. Anyone else have an idea?
Clemens
More information about the rrd-users
mailing list