def main(): import optparse parser = optparse.OptionParser('usage: %prog OPTIONS\n' + __doc__) parser.add_option('-f', '--watchFilePattern', action='append', default=[], help='Watch for files matching the specified UNIX glob, like "somedir/*.jpg"') parser.add_option('-d', '--watchDirectory', action='append', default=[], help='Watch for files in the specified directory') parser.add_option('-s', '--watchSymlink', action='append', default=[], help='Watch for files pointed to by the specified symlink. This assumes a cooperative file writer that updates a symlink whenever it writes a new file. This may be more efficient than the other approaches when new files are appearing in a directory containing many files.') parser.add_option('-t', '--subtopic', default='standard', help='Subtopic to use when publishing zmq message [%default]') ZmqPublisher.addOptions(parser, 'filePublisher.{subtopic}') ZmqSubscriber.addOptions(parser, 'filePublisher.{subtopic}') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.DEBUG) p = FilePublisher(opts) p.start() zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') ZmqSubscriber.addOptions(parser, 'rasterMapIndexer') parser.add_option('--timeSeries', help='Specify a comma-separated subset of time series to index') parser.add_option('-c', '--clean', action='store_true', default=False, help='Clean out old raster map data at startup') parser.add_option('-q', '--quit', action='store_true', default=False, help='Quit after initial indexing is complete') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.INFO) # insure atexit handlers are called on receiving SIGINT or SIGTERM def sigHandler(signo, frame): logging.warn('caught signal %s, exiting', signo) sys.exit(0) for sig in (signal.SIGINT, signal.SIGTERM): signal.signal(sig, sigHandler) rmi = RasterMapIndexer(opts) if opts.clean: rmi.clean() rmi.start() atexit.register(rmi.stop) if not opts.quit: zmqLoop()
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, 'xgdsPlotIndexer') parser.add_option('-c', '--clean', action='store_true', default=False, help='Delete indexes and start from scratch') parser.add_option('-q', '--quit', action='store_true', default=False, help='Quit after initial indexing is complete') parser.add_option('--timeSeries', help='Comma-separated list of time series to index (by default index all)') opts, args = parser.parse_args() if args: parser.error('expected no arguments') logging.basicConfig(level=logging.INFO) # insure atexit handlers are called on receiving SIGINT or SIGTERM def sigHandler(signo, frame): logging.warn('caught signal %s, exiting', signo) sys.exit(0) for sig in (signal.SIGINT, signal.SIGTERM): signal.signal(sig, sigHandler) x = XgdsPlotIndexer(opts) if opts.clean: x.clean() x.start() atexit.register(x.stop) if not opts.quit: zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') ZmqSubscriber.addOptions(parser, 'tracLinkTelemetryCleanup') ZmqPublisher.addOptions(parser, 'tracLinkTelemetryCleanup') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.DEBUG) d = TracLinkTelemetryCleanup(opts) d.start() atexit.register(d.flush) zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') parser.add_option('-p', '--port', type='int', default=8001, help='TCP port where websocket server should listen [%default]') ZmqSubscriber.addOptions(parser, 'zmqProxy') opts, args = parser.parse_args() if args: parser.error('expected no args') global proxyG proxyG = ZmqProxy(opts) proxyG.start() 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()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') parser.add_option( '-p', '--port', type='int', default=8001, help='TCP port where websocket server should listen [%default]') ZmqSubscriber.addOptions(parser, 'zmqProxy') opts, args = parser.parse_args() if args: parser.error('expected no args') global proxyG proxyG = ZmqProxy(opts) proxyG.start() zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog OPTIONS\n' + __doc__) parser.add_option('-o', '--output', default='.', help='Directory to write received files to [%default]') parser.add_option('-p', '--pollPeriod', type='float', default=1.0, help='Period between checks for a new latest file (seconds) [%default]') parser.add_option('-s', '--timestampSpacing', type='float', default=5.0, help='Ignore latest file unless it is this much newer than the last file sent (seconds) [%default]') parser.add_option('--timeout', type='float', default=30.0, help='Keep publishing files for this long after each request from fileReceiver (seconds) [%default]') parser.add_option('-r', '--imageResize', help='Subsample any images to specified size (e.g. "640x480")') parser.add_option('-c', '--imageCrop', help='Crop any images to specified size and location (e.g. "100x100+300+400")') parser.add_option('-f', '--imageFormat', help='Output any images in the specified format (e.g. "jpg")') parser.add_option('-t', '--subtopic', default='standard', help='Subtopic to use when receiving zmq message [%default]') parser.add_option('-n', '--noRequest', action='store_true', default=False, help='Do not request any files from filePublisher, but write any files that are received, for example because they are requested by other receivers. May be useful for debugging.') ZmqPublisher.addOptions(parser, 'fileReceiver.{subtopic}') ZmqSubscriber.addOptions(parser, 'fileReceiver.{subtopic}') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.DEBUG) p = FileReceiver(opts) p.start() zmqLoop()
def main(): import optparse parser = optparse.OptionParser('usage: %prog') ZmqSubscriber.addOptions(parser, 'rasterMapIndexer') parser.add_option( '--timeSeries', help='Specify a comma-separated subset of time series to index') parser.add_option('-c', '--clean', action='store_true', default=False, help='Clean out old raster map data at startup') parser.add_option('-q', '--quit', action='store_true', default=False, help='Quit after initial indexing is complete') opts, args = parser.parse_args() if args: parser.error('expected no args') logging.basicConfig(level=logging.INFO) # insure atexit handlers are called on receiving SIGINT or SIGTERM def sigHandler(signo, frame): logging.warn('caught signal %s, exiting', signo) sys.exit(0) for sig in (signal.SIGINT, signal.SIGTERM): signal.signal(sig, sigHandler) rmi = RasterMapIndexer(opts) if opts.clean: rmi.clean() rmi.start() atexit.register(rmi.stop) if not opts.quit: zmqLoop()