Example #1
0
    def send(self, data, ns=None, ts=None):
        if ts is None:
            ts = time.time()

        if ns is None:
            final_ns = self.ns
        else:
            final_ns = thing.stringify_ns(self.ns_parts + thing.parse_ns(ns))

        msg = {
            "type": "thing_update",
            "ns": final_ns,
            "documentation_url": self.documentation_url,
            "data": data,
            "ts": ts,
        }

        self.msg_q.put(msg)
Example #2
0
    def __init__(self, ns, documentation_url, broker_input_url=None, zone=None, verbose=False):

        if (zone is None) and (broker_input_url is None):
            raise RuntimeError("Must supply zone or broker_input_url")
        if not ns:
            raise RuntimeError("ns must be set.")

        self.verbose = verbose
        self.zone = zone
        self._broker_input_url = broker_input_url

        self.ns = ns
        self.ns_parts = thing.parse_ns(ns)
        self.documentation_url = documentation_url

        self.ok = True
        self.msg_q = Queue.Queue()

        threading.Thread.__init__(self)
        self.daemon = True
        self.start()