def main(): import optparse parser = optparse.OptionParser('usage: %prog <prefix>') parser.add_option('-p', '--pretty', action='store_true', default=False, help='Pretty-print JSON objects') ZmqSubscriber.addOptions(parser, 'zmqGrep') opts, args = parser.parse_args() if len(args) != 1: parser.error('expected exactly 1 arg') logging.basicConfig(level=logging.DEBUG) # set up networking s = ZmqSubscriber(**ZmqSubscriber.getOptionValues(opts)) s.start() # subscribe to the message we want topic = args[0] if opts.pretty: s.subscribeJson(topic, handleMessagePretty) else: s.subscribeRaw(topic, handleMessageSimple) zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') ZmqSubscriber.addOptions(parser, 'testSubscriber') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.DEBUG) # set up networking s = ZmqSubscriber(**ZmqSubscriber.getOptionValues(opts)) s.start() # subscribe to the message we want s.subscribe('geocamUtil.greeting:', handleGreeting) zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') ZmqSubscriber.addOptions(parser, 'testSubscriber') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.DEBUG) # set up networking s = ZmqSubscriber(**ZmqSubscriber.getOptionValues(opts)) s.start() # subscribe to the message we want s.subscribeRaw('geocamUtil.greeting:', handleGreeting) zmqLoop()
class ZmqProxy(object): def __init__(self, opts): self.opts = opts self.subscriber = ZmqSubscriber(**ZmqSubscriber.getOptionValues(self.opts)) self.application = tornado.web.Application([ (r"^/?$", MainHandler), (r"^/zmq/$", ClientSocket), ]) def start(self): # initialize zmq self.subscriber.start() # start serving web clients print 'binding to port %d' % self.opts.port self.application.listen(self.opts.port)
class ZmqProxy(object): def __init__(self, opts): self.opts = opts self.subscriber = ZmqSubscriber( **ZmqSubscriber.getOptionValues(self.opts)) self.application = tornado.web.Application([ (r"^/?$", MainHandler), (r"^/zmq/$", ClientSocket), ]) def start(self): # initialize zmq self.subscriber.start() # start serving web clients print 'binding to port %d' % self.opts.port self.application.listen(self.opts.port)