diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2013-01-20 23:53:52 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2013-01-20 23:53:52 +0100 |
commit | 1068ff9bf74cf411be701bb50fae92e8476b5da7 (patch) | |
tree | 5f54b2cb37bace46a0508544ec5116468c8f584b /datastore/store | |
parent | a40afda64c61089d6c108eea9cb3eac8aeaaa072 (diff) | |
download | ebus-alt-1068ff9bf74cf411be701bb50fae92e8476b5da7.tar.gz ebus-alt-1068ff9bf74cf411be701bb50fae92e8476b5da7.zip |
datastore foo
Diffstat (limited to 'datastore/store')
-rw-r--r-- | datastore/store/channel.py | 2 | ||||
-rw-r--r-- | datastore/store/controller.py | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/datastore/store/channel.py b/datastore/store/channel.py index 2a5d5f4..1e083b5 100644 --- a/datastore/store/channel.py +++ b/datastore/store/channel.py @@ -7,7 +7,7 @@ class PrinterChannel(IChannel): def __init__(self,name): self.name = name def add(self,timestamp,data,controller): - print "{0}: {1},{2}".format(self.name, timestamp, data) + print "{0}: timestamp={1} value={2}".format(self.name, timestamp, data) class SimpleMemoryChannel(IChannel): def __init__(self): diff --git a/datastore/store/controller.py b/datastore/store/controller.py index 0814488..0d694d1 100644 --- a/datastore/store/controller.py +++ b/datastore/store/controller.py @@ -1,4 +1,5 @@ import traceback +import time class SubscriptionManager: def __init__(self): @@ -56,13 +57,16 @@ class StoreController: class MQStoreController(StoreController): def cb_put(self, frame): try: + if not frame.headers.has_key("timestamp"): + frame.headers['timestamp'] = str(time.time()) assert len(frame.timestamp) > 0 values = map(lambda kv: kv.split("="), frame.body.split("\n")) + values = filter(lambda x: len(x)==2, values) #filter non-pairs from empty lines for (name,data) in values: - assert self.channels.has_key(name) + if name not in self.channels.keys(): + print "No channel named {0}".format(name) + continue print name,"=",data - - for (name,data) in values: self.put(name, frame.timestamp, data) except Exception,e: traceback.print_exc() |