summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-05-31 19:53:59 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-05-31 19:53:59 +0000
commit0390d8cbca750240259269a9f0c85dc342ceb19e (patch)
treecb3dc2a8cba235be271d00a0288b351cb468a5e8
parent3a22b83633fe07ff0b689284433a53c20ea58466 (diff)
downloadebus-alt-0390d8cbca750240259269a9f0c85dc342ceb19e.tar.gz
ebus-alt-0390d8cbca750240259269a9f0c85dc342ceb19e.zip
add ebus_app
git-svn-id: http://10.2.2.13/svn/common/ebus@1670 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rwxr-xr-xbin/ebus_app30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/ebus_app b/bin/ebus_app
new file mode 100755
index 0000000..d381254
--- /dev/null
+++ b/bin/ebus_app
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# -*- coding:utf8 -*-
+# xapek.org, 2010
+import asyncore
+from pymongo import Connection
+from ebus import EbusReader
+from time import time
+
+connection = Connection("10.2.2.13", 27017)
+db = connection["ebus"]
+db.authenticate("ebus", "ebus")
+collection = db["data"]
+
+def insert(ebus_packet):
+ try:
+ if ebus_packet.values() != dict():
+ data={'name':ebus_packet.name(), 'values':ebus_packet.values(), 'time':time()}
+ collection.insert(data)
+ print "Inserted: %s" % data
+ except Exception,e:
+ try:
+ print "Failed to insert %s -- %s" % (ebus_packet.name(), e)
+ except Exception,e:
+ print e
+
+reader = EbusReader()
+reader.handle_ebus = insert
+reader.debug = False
+
+asyncore.loop()