diff options
author | yvesf <yvesf-git@xapek.org> | 2010-08-15 22:54:27 +0200 |
---|---|---|
committer | yvesf <yvesf-git@xapek.org> | 2010-08-15 22:54:27 +0200 |
commit | 7ff580a6fe60f7e3ea160f7b181ff0fa934453ce (patch) | |
tree | 55ea82fdffaaf50ed099f3bc663cb083952d1fc5 /bin/ebus_dump.py | |
parent | 3e70cb0892a703888e913ee5a1545f488a22a4a3 (diff) | |
download | ebus-alt-7ff580a6fe60f7e3ea160f7b181ff0fa934453ce.tar.gz ebus-alt-7ff580a6fe60f7e3ea160f7b181ff0fa934453ce.zip |
So 15. Aug 22:54:27 CEST 2010
Diffstat (limited to 'bin/ebus_dump.py')
-rwxr-xr-x | bin/ebus_dump.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/bin/ebus_dump.py b/bin/ebus_dump.py index bfae56e..a437b0d 100755 --- a/bin/ebus_dump.py +++ b/bin/ebus_dump.py @@ -2,15 +2,33 @@ # -*- coding:utf8 -*- import asyncore 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 + +engine = create_engine('sqlite:///:memory:', echo=True) +#engine = create_engine("postgresql://yvesf:iii@10.2.2.13:5432/yvesf", echo=True) + +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.debug = True + self.sql = EbusSQL(session) def handle_ebus(self,ebus_packet): - if ebus_packet.values() != dict(): - print ebus_packet + for field in self.sql.get_values(ebus_packet): + session.add(field) MyEbusReader() -asyncore.loop() +try: + asyncore.loop() +except KeyboardInterrupt: + for data in session.query(Value).all(): + print data |