Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
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()
Beispiel #4
0
def main():
    import optparse
    parser = optparse.OptionParser('usage: %prog <zmqCentral-messages-xxx.txt>')
    parser.add_option('-t', '--topic',
                      action='append',
                      help='Only print specified topics, can specify multiple times')
    ZmqPublisher.addOptions(parser, 'zmqPlayback')
    opts, args = parser.parse_args()
    if len(args) != 1:
        parser.error('expected exactly 1 arg')
    logging.basicConfig(level=logging.DEBUG)

    pb = ZmqPlayback(args[0], opts)
    pb.start()

    zmqLoop()
Beispiel #5
0
def main():
    import optparse
    parser = optparse.OptionParser('usage: testLineSource.py testMessages.txt | %prog')
    ZmqPublisher.addOptions(parser, 'testPublisher')
    opts, args = parser.parse_args()
    if args:
        parser.error('expected no args')
    logging.basicConfig(level=logging.DEBUG)

    # set up networking
    publisher = ZmqPublisher(**ZmqPublisher.getOptionValues(opts))
    publisher.start()

    ioloop.IOLoop.instance().add_handler(sys.stdin.fileno(),
                                         lambda fd, events: stdinHandler(publisher),
                                         ioloop.IOLoop.READ)
    zmqLoop()
Beispiel #6
0
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')
    ZmqPublisher.addOptions(parser, 'testPublishAttachments')
    opts, args = parser.parse_args()
    if args:
        parser.error('expected no args')
    logging.basicConfig(level=logging.DEBUG)

    # set up networking
    p = ZmqPublisher(**ZmqPublisher.getOptionValues(opts))
    p.start()

    # start publishing an arbitrary message that central should forward
    pubTimer = ioloop.PeriodicCallback(lambda: pubMessage(p), 1000)
    pubTimer.start()

    zmqLoop()
Beispiel #8
0
def main():
    import optparse
    parser = optparse.OptionParser('usage: %prog')
    ZmqPublisher.addOptions(parser, 'zmqPublish')
    parser.add_option('-p', '--prefix',
                      default='',
                      help='Prefix to prepend to incoming lines before publishing them (DO include trailing "." if you want it)')
    opts, args = parser.parse_args()
    if args:
        parser.error('expected no args')
    logging.basicConfig(level=logging.DEBUG)

    # set up networking
    p = ZmqPublisher(**ZmqPublisher.getOptionValues(opts))
    p.start()

    # start publishing an arbitrary message that central should forward
    pubTimer = ioloop.PeriodicCallback(lambda: pubMessage(opts.prefix, p), 0.1)
    pubTimer.start()

    zmqLoop()
Beispiel #9
0
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()
Beispiel #10
0
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()
Beispiel #11
0
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()