#!/usr/bin/env python import json import pprint from twisted.internet import reactor, defer from txZMQ import ZmqEndpoint, ZmqFactory, ZmqPubConnection, ZmqSubConnection zf = ZmqFactory() e = ZmqEndpoint("connect", "tcp://higgs:9901") s = ZmqSubConnection(zf, e) s.subscribe("") # ("scheduler.scheduler001.new_interval") def on_message(*args): # json_str = args[0] pprint.pprint(args) # json_obj = json.loads(json_str) # pprint.pprint(json_obj) s.gotMessage = on_message reactor.run()
if query is None: query = list() tags = set(tags.split(" ")) query = set(query) return query.issubset(tags) def on_message(detail, tags): print "Tags: %s" % (tags) detail = json.loads(detail) pc.publish("Testing") if matches(tags, ["c:owfs"]): print "OWFS FTW!" pc.publish("HELLO") if matches(tags, ["c:tivo", "o:channel"]): print detail channel = detail.get("channel") if channel == 101: print "BBC1" sc.gotMessage = on_message reactor.run()