From 862282ce99760832d3e9e5b4b1171b861105e004 Mon Sep 17 00:00:00 2001 From: Ebus-at-dockstar Date: Mon, 25 Mar 2013 10:24:28 +0100 Subject: move old stuff away --- bin/ebus | 1 - bin/ebus_app.py | 41 ------------------------------ bin/ebus_dump.py | 49 ------------------------------------ bin/web_dev.py | 9 ------- bin/web_prod.py | 9 ------- bin/wettermichel.py | 72 ----------------------------------------------------- 6 files changed, 181 deletions(-) delete mode 120000 bin/ebus delete mode 100755 bin/ebus_app.py delete mode 100755 bin/ebus_dump.py delete mode 100755 bin/web_dev.py delete mode 100755 bin/web_prod.py delete mode 100755 bin/wettermichel.py (limited to 'bin') diff --git a/bin/ebus b/bin/ebus deleted file mode 120000 index 1232ff3..0000000 --- a/bin/ebus +++ /dev/null @@ -1 +0,0 @@ -../ebus/ \ No newline at end of file diff --git a/bin/ebus_app.py b/bin/ebus_app.py deleted file mode 100755 index c9b89f6..0000000 --- a/bin/ebus_app.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- -# xapek.org, 2010 -import asyncore -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -from ebus.web import model -from ebus import EbusReader - -#db_engine = create_engine('sqlite:///:memory:', echo=True) -db_engine = create_engine("postgresql://yvesf:iii@10.2.2.13:5432/yvesf", echo=True) - -session = sessionmaker(bind=db_engine)() - - -def insert(ebus_packet): - try: - for valueKey in ebus_packet.values().keys(): - print "Key", valueKey - sensor = session.query(model.Sensor).filter(model.Sensor.name==valueKey).first() - if not sensor: - print "Add sensor %s" % valueKey - sensor = model.Sensor(valueKey) - session.add(sensor) - print sensor - m_value = model.Value(sensor, ebus_packet.values()[valueKey]) - session.add(m_value) - print m_value - session.commit() - except Exception,e: - session.rollback() - try: - print "Failed to insert %s -- reason %s" % (ebus_packet.name(), e) - except Exception,e: - print e - -reader = EbusReader() -reader.handle_ebus = insert -reader.debug = False - -asyncore.loop() diff --git a/bin/ebus_dump.py b/bin/ebus_dump.py deleted file mode 100755 index c170849..0000000 --- a/bin/ebus_dump.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf8 -*- -import asyncore -import time -from ebus import EbusReader -from ebus.model.sql import ModelBase, EbusSQL, Value -from ebus.model.sql import EbusSQL -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -import logging - -logging.basicConfig() - -#logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) -logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) - -logger = logging.getLogger('ebus.dump') -logger.setLevel(logging.INFO) - -#engine = create_engine('sqlite:///:memory:', echo=True) -engine = create_engine("postgresql:///ebus") - -ModelBase.metadata.create_all(engine) - -Session = sessionmaker() -Session.configure(bind=engine) -session = Session() - - -class MyEbusReader(EbusReader): - def __init__(self,*args,**kwargs): - EbusReader.__init__(self,*args,**kwargs) - self.debug = True - self.sql = EbusSQL(session) - def handle_ebus(self,ebus_packet): - for field in self.sql.get_values(ebus_packet): - session.add(field) - - session.commit() - - logger.info("packet %s" % ebus_packet.name()) - -MyEbusReader() -try: - asyncore.loop() -except KeyboardInterrupt: - pass -# for data in session.query(Value).all(): -# print data diff --git a/bin/web_dev.py b/bin/web_dev.py deleted file mode 100755 index 8c45f0b..0000000 --- a/bin/web_dev.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -import bottle -from ebus import webhdf - -if __name__ == "__main__": - bottle.debug(True) - - bottle.run(webhdf.app, host="0.0.0.0", port=8080, reloader=True) diff --git a/bin/web_prod.py b/bin/web_prod.py deleted file mode 100755 index 97bf39c..0000000 --- a/bin/web_prod.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -import bottle -from ebus import webhdf - -if __name__ == "__main__": - bottle.debug(False) - - bottle.run(webhdf.app, host="0.0.0.0", port=8000, reloader=False) diff --git a/bin/wettermichel.py b/bin/wettermichel.py deleted file mode 100755 index 57b517a..0000000 --- a/bin/wettermichel.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf8 -*- -import httplib -from StringIO import StringIO - -from lxml import objectify - -from sqlalchemy import create_engine, text -from sqlalchemy.ext.sqlsoup import SqlSoup - -soup = SqlSoup( - create_engine("postgresql://ebus:ebus@10.2.2.26:5432/ebus") ) - -def read(): - conn = httplib.HTTPConnection("www.wettermichel.de") - conn.request("GET", "/weatherdata/params3.xml") - result = conn.getresponse() - assert result.status == 200, 'Site answered with Status 200' - - xml = objectify.parse( result ) - conn.close() - return xml - -def get_sensor_id(sensor_name): - try: - sensor_id = soup.sensor.filter(soup.sensor.name == sensor_name).one() - return sensor_id.id - except: - conn = soup.connection() - conn.execute(text("""INSERT INTO sensor(name) VALUES (:name)"""), - name = sensor_name) - soup.commit() - return soup.sensor.filter(soup.sensor.name == sensor_name).one().id - -def insert(sensor_name,value_int=None, value_float=None, value_string=None): - sql = text("""INSERT INTO value( - timestamp, sensor_id, type, value_int, value_float, value_string) - VALUES ( - NOW(), :sensor_id, :type, :value_int, :value_float, :value_string)""") - conn = soup.connection() - ttype = value_int != None and "int" or \ - value_float != None and "float" or \ - value_string != None and "string" or \ - None - assert ttype != None, 'ttype is set' - conn.execute(sql, sensor_id=get_sensor_id(sensor_name), - type=ttype, - value_int=value_int, - value_float=value_float, - value_string=value_string) - soup.commit() - -############### - -xml = read() -for keyval in xml.xpath("/data/*"): - if keyval.tag == "entry": - continue - - if isinstance(keyval, objectify.IntElement): - insert("de.wettermichel.%s"%keyval.tag, - value_int=int(keyval.text)) - elif isinstance(keyval, objectify.FloatElement): - insert("de.wettermichel.%s"%keyval.tag, - value_float=float(keyval.text)) - elif isinstance(keyval, objectify.StringElement): - insert("de.wettermichel.%s"%keyval.tag, - value_string=keyval.text) - else: - print "ignore other: %s %s" % (keyval.tag, keyval.__class__) - - -- cgit v1.2.1