result = sorted(groups, key=len, reverse=True)[0]
return {'response': result, 'version': self.version}
+ def parse_time(self, str):
+ """Parse a time, either as unix time or a ISO timestamp"""
+ try:
+ return int(str)
+ except ValueError:
+ return int(dateparser.parse(str).timestamp())
+
+ def get_ascii(self, data):
@cherrypy.expose
def download(self, *args, **kwargs):
try:
if param_from is None or param_until is None:
raise Exception("must provide both from and to parameters")
else:
- data = self.get_since(int(param_from), int(param_until))
+ param_from = self.parse_time(param_from)
+ param_until = self.parse_time(param_until)
+ data = self.get_since(param_from, param_until)
if cherrypy.request.params.get('type') == 'text':
cherrypy.response.headers['content-type'] = 'text/plain'
raise Exception("not implemented")
-<!doctype html>
+<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
}
function on_download(mimetype)
{
- if (document.custom.graph) {
- var axes = document.custom.graph.getAxes()
+ if (document.custom.graph_main) {
+ var axes = document.custom.graph_main.plot.getAxes()
var upper = parseInt(axes.xaxis.max / 1000);
var lower = parseInt(axes.xaxis.min / 1000);
var url = 'download?type=' + mimetype + '&from=' + lower + '&to=' + upper;