Added /export route
This commit is contained in:
@ -3,6 +3,7 @@ import time
|
||||
import logging
|
||||
from colors import assign_colors_to_curves
|
||||
import json
|
||||
import io
|
||||
|
||||
class InfluxGraph:
|
||||
"""
|
||||
@ -162,6 +163,27 @@ class InfluxGraph:
|
||||
self.livemode = self.LIVE
|
||||
return dict(type='accept-graph', live=True)
|
||||
|
||||
def w_export(self, variables, time, interval):
|
||||
"""
|
||||
Returns the bytes of a dataframe with the curves given by variables in the time range "time"
|
||||
Called when the route /export is reached.
|
||||
|
||||
Parameters :
|
||||
variables (str) : a comma separataed value string of variable names (influx names) to retrieve
|
||||
time (str) : a commma separated value string (range) of seconds.
|
||||
interval (str) : the interval (resolution) of the values to get (string in seconds)
|
||||
|
||||
Returns :
|
||||
io.BytesIO : an BytesIO object containing the dataframe to retrieve
|
||||
"""
|
||||
df = self.influx_data_getter.get_curves_data_frame(variables, time, interval)
|
||||
|
||||
mem = io.BytesIO()
|
||||
mem.write(bytes(df.to_csv(sep="\t", index=False), "utf-8"))
|
||||
mem.seek(0)
|
||||
|
||||
return mem
|
||||
|
||||
def graphpoll(self):
|
||||
"""
|
||||
Polls the last known values for all the available variables, and returns only those whose polled value is more recent than the nost recent displayed one.
|
||||
|
Reference in New Issue
Block a user