Can this be done without storing the image if it's only needed the one time?
On Wednesday, April 4, 2012 4:45:50 PM UTC-4, dancer` wrote: > > Thank you very much. > > One more thing - if I understand correctly this allows me to keep my data > buffer clean and not worry about overwriting plots. Is it possible to use a > date/time unique naming format to automatically name the image files and > store them, say, in the static folder? Or somewhere else, if there's an > issue? > > Thanks again. > > On Wednesday, April 4, 2012 4:39:59 PM UTC-4, Massimo Di Pierro wrote: >> >> Makes perfect sense. >> >> When you use matplotlib you can do: >> >> You can store the image in temp file: >> >> import tempfile >> f = tempfile.NamedTemporaryFile() >> canvas = FigureCanvas(figure) >> canvas.print_png(f) >> filename = f.name >> f.close() >> >> then move it to the db in a field called for example file of type upload >> >> db.table.insert(file = db.table.file.store(filename=filename) >> >> then read the file, delete, and return the image >> >> data = open(filename,'rb').read() >> os.unlink(filename) >> return data >> >> >> On Wednesday, 4 April 2012 13:50:12 UTC-5, dancer` wrote: >>> >>> Hello, >>> >>> I'm on the newer end of programming, and web2py has been my first (and >>> very happy) foray into web application development. I am developing an >>> application to remotely control two spectrum analyzers (HP 3562A) in our >>> lab to do swept sine and power spectra plots. The connection is made using >>> sockets, and the data is dumped, modified, and plotted using numpy, scipy >>> and matplotlib. The examples I have found that do this do not mention how >>> to store the resulting plots on disk but rather plot in real time when >>> required. What I would like is to have a results table with all the run >>> parameters (for both sweeps and PSD) and have a thumbnail image (I know how >>> to generate a thumbnail if I have a parent file) that links to the original >>> plotted image. Is this possible, or am I approaching this the wrong way? >>> >>> Thank you. >>> >>