Exemplo n.º 1
0
 def export_json(self, subplot, line):
     plot = Plot.frompref()
     sp = plot.subplots[int(subplot) - 1]
     line = sp.lines[int(line)]
     web.setmime(web.mime.csv)
     io = StringIO()
     line.export_json(io, plot.startdate, plot.enddate)
     io.seek(0)
     return io
Exemplo n.º 2
0
 def linedatasets_json(self, subplot, line):
     web.setmime(web.mime.json)
     plot = Plot.frompref()
     sp = plot.subplots[int(subplot) - 1]
     line = sp.lines[int(line)]
     session = db.Session()
     datasets = line.getdatasets(session)
     res = web.as_json(datasets)
     session.close()
     return res
Exemplo n.º 3
0
 def exportall_csv(self, tolerance):
     plot = Plot.frompref()
     #         datasetids=[]
     #         session=db.Session()
     #         for sp in plot.subplots:
     #             for line in sp.lines:
     #                 datasetids.extend(ds.id for ds in line.getdatasets(session))
     #         session.close()
     lines = []
     for sp in plot.subplots:
         lines.extend(sp.lines)
     stream = StringIO()
     from tools.exportdatasets import exportLines
     exportLines(stream, lines, web.conv(float, tolerance, 60))
     web.setmime(web.mime.csv)
     return stream.getvalue()
Exemplo n.º 4
0
 def RegularTimeseries_csv(self, tolerance=12, interpolation=''):
     plot = Plot.frompref()
     datasetids = []
     session = db.Session()
     lines = []
     for sp in plot.subplots:
         lines.extend(sp.lines)
         for line in sp.lines:
             datasetids.extend(ds.id for ds in line.getdatasets(session))
     session.close()
     stream = StringIO()
     from tools.ExportRegularData import createPandaDfs
     # explicit decode() for byte to string
     stream.write(codecs.BOM_UTF8.decode())
     createPandaDfs(lines,
                    plot.startdate,
                    plot.enddate,
                    stream,
                    interpolationtime=interpolation,
                    tolerance=float(tolerance))
     web.setmime(web.mime.csv)
     return stream.getvalue()
Exemplo n.º 5
0
 def image_pdf(self, **kwargs):
     web.setmime(web.mime.pdf)
     plot = Plot.frompref()
     if not plot:
         raise web.HTTPRedirect('/plot?error=No plot available')
     return plot.draw(format='pdf')
Exemplo n.º 6
0
 def listplotfiles(self):
     web.setmime(web.mime.json)
     return web.as_json(Plot.listdir())