Ejemplo n.º 1
0
def uris_for_prefixes(self):
    prefixes = self.get_arguments('prefix')

    services = set()
    for pfx in prefixes:
        for svc in (Service.for_prefix(pfx)):
            services.add(svc)

    return {svc.prefix: list(svc.URIs) for svc in services}
Ejemplo n.º 2
0
def uris_for_prefixes(self):
    prefixes = self.get_arguments('prefix')

    services = set()
    for pfx in prefixes:
        for svc in (Service.for_prefix(pfx)):
            services.add(svc)

    return {svc.prefix: list(svc.URIs) for svc in services}
Ejemplo n.º 3
0
def main():
    """
    run the app!
    currently very hairy. starts with dummy data
    """
    conf = Config('squidwork.web.monitor')
    conf.option('cache-size', type=int, help='numer of elements to store')
    conf.option('display-size', type=int, help='numer of elements to store')
    conf.retrieve()

    settings = dict(debug=conf.debug,
                    template_path=os.path.dirname(os.path.realpath(__file__)))
    port = conf.port

    # the message buffer stores the last N mesages
    cache = MessageCache(conf.cache_size)

    # subscribe to all services!
    uris = Service.all_uris()
    recvr = AsyncReciever(sub(*uris))
    recvr.on_recieve(cache.add)

    # generate some dummy data to pre-populate the cache with
    dummy = [dummy_message() for i in range(0, 20)]
    cache.add(*dummy)

    # we include the api_handlers from squidwork.web so we can use the
    # squidwork web<--WebSocket-->ZeroMq bridge
    all_handlers = api_handlers(conf.raw_config, debug=conf.debug) + [

        # the index page is totally static -- all it does is request javascript
        (r"/", TemplateRenderer, dict(source='templates/index.html')),

        # JSON view of whatever is currently in our cache. this is how the
        # app gets its initial data on page load
        (r"/data.json", JSONHandler, dict(encoder=MessageEncoder, data=(
            lambda: {'latest': cache.cache, 'types': cache.by_origin}))),

        # big coffeescript app written with Mithril.js. All HTML structure on
        # the page is produced by view functions in app.coffee
        (r"/app.js", CoffeescriptHandler,
            dict(source='templates/app.coffee', count=conf.display_size)),

        # static, plain-jane scss
        (r"/style.css", ScssHandler, dict(source='templates/style.scss')),
    ]

    # spin up the app!
    app = tornado.web.Application(all_handlers, **settings)
    try:
        app.listen(port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        print ' keyboard interrupt: exiting.'
Ejemplo n.º 4
0
def main():
    # we don't care about the value because we're only interested in service
    # definitions. Unfortunatley you may need a dummy service definition
    Config().retrieve()
    uris = Service.all_uris()

    if len(uris) == 0:
        print('No URIs! Exiting.')
        return

    print('Will listen to uris: ' + str(uris))

    for u in uris:
        create_listener_thread(u).start()

    try:
        while True:
            sleep(1)
    except KeyboardInterrupt:
        print(' keyboard interrupt, exiting.')
        return
Ejemplo n.º 5
0
def main():
    # we don't care about the value because we're only interested in service
    # definitions. Unfortunatley you may need a dummy service definition
    Config().retrieve()
    uris = Service.all_uris()

    if len(uris) == 0:
        print('No URIs! Exiting.')
        return

    print('Will listen to uris: ' + str(uris))

    for u in uris:
        create_listener_thread(u).start()

    try:
        while True:
            sleep(1)
    except KeyboardInterrupt:
        print(' keyboard interrupt, exiting.')
        return