From feebdc2e14426921a585c31c5279886bca3e2eca Mon Sep 17 00:00:00 2001 From: yvesf Date: Wed, 9 Jun 2010 11:14:18 +0000 Subject: foo git-svn-id: http://10.2.2.13/svn/common/ebus@1676 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd --- ebus/web/controller.py | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 ebus/web/controller.py (limited to 'ebus/web/controller.py') diff --git a/ebus/web/controller.py b/ebus/web/controller.py new file mode 100644 index 0000000..f3fa438 --- /dev/null +++ b/ebus/web/controller.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import sys, os, time +sys.path.insert(0,"lib") +from itty import itty +from werkzeug.contrib.cache import SimpleCache +from simplejson import dumps as dump_json + +""" +def data(name): + if name in ( + "solarDaten.tempKollektor", + "solarDaten.tempWarmwasserSolar", + "betriebsdatenRegler1.boilerTemperatur", + "betriebsdatenRegler1.kesselTemperatur", + "betriebsdatenRegler1.aussenTemperatur", + "betriebsdatenFeuerungsautomat.brauchwasserSollwert", + "betriebsdatenFeuerungsautomat.kesselSollwertTemperatur"): + m = Code(''' + function () { + emit(parseInt(this.time/900)*900000, {sum: this.values[field], count:1}); + }''') + r = Code(''' + function (key, values) { + var n = { sum:0, count:0 }; + for (var i = 0; i') +def json(req,name): + value = json_cache.get(name) + if value is None: + value = deny.Response(dump_json(dict(map(lambda r: (r, {"label":r, "data":data(r)}), name.split(",")))), mimetype='application/json') + json_cache.set(name, value) + return value + +@itty.get("/static/(?P.+)") +def static(request,filename): + file = itty.static_file(filename, root=os.path.join(os.path.dirname(__file__), 'static')) + return itty.Response(file, content_type=itty.content_type(file)) + +if __name__ == '__main__': + sys.exit(itty.run_itty(host="0.0.0.0",port=5000)) -- cgit v1.2.1