summaryrefslogtreecommitdiff
path: root/heap/bin/ebus_dump.py
diff options
context:
space:
mode:
authorEbus-at-dockstar <ebus@dockstar>2013-03-25 10:24:28 +0100
committerEbus-at-dockstar <ebus@dockstar>2013-03-25 10:24:43 +0100
commit862282ce99760832d3e9e5b4b1171b861105e004 (patch)
tree0e229418e391917b79d42a8bdee46fb7a8612895 /heap/bin/ebus_dump.py
parent9522cdffa94f278eb5e1894600535986e22c2890 (diff)
downloadebus-alt-862282ce99760832d3e9e5b4b1171b861105e004.tar.gz
ebus-alt-862282ce99760832d3e9e5b4b1171b861105e004.zip
move old stuff away
Diffstat (limited to 'heap/bin/ebus_dump.py')
-rwxr-xr-xheap/bin/ebus_dump.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/heap/bin/ebus_dump.py b/heap/bin/ebus_dump.py
new file mode 100755
index 0000000..c170849
--- /dev/null
+++ b/heap/bin/ebus_dump.py
@@ -0,0 +1,49 @@
+#!/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