Ejemplo n.º 1
0
def test_create_no_args(sys_args, app_config, mocker):
    mocker.patch(TESTED + '.sys.argv', sys_args)

    with pytest.raises(AssertionError):
        service.create_app()

    app = service.create_app(default_name='default')

    assert app['config'] == app_config
Ejemplo n.º 2
0
def main():
    app = service.create_app(default_name='ispindel')

    # Init events
    add_events(app)

    # Register routes
    app.router.add_routes(routes)

    # Add all default endpoints, and adds prefix to all endpoints
    #
    # Default endpoints are:
    # {prefix}/api/doc (Swagger documentation of endpoints)
    # {prefix}/_service/status (Health check: this endpoint is called to check service status)
    #
    # The prefix is automatically added for all endpoints. You don't have to do anything for this.
    # To change the prefix, you can use the --name command line argument.
    #
    # See brewblox_service.service for more details on how arguments are parsed.
    #
    # The default value is "YOUR_PACKAGE" (provided in service.create_app()).
    # This means you can now access the example/endpoint as "/YOUR_PACKAGE/example/endpoint"
    service.furnish(app)

    # service.run() will start serving clients async
    service.run(app)
Ejemplo n.º 3
0
def test_create_w_parser(sys_args, app_config, mocker):
    parser = service.create_parser('brewblox')
    parser.add_argument('-t', '--test', action='store_true')

    sys_args += ['-t']
    app = service.create_app(parser=parser, raw_args=sys_args[1:])
    assert app['config']['test'] is True
Ejemplo n.º 4
0
def main():
    app = service.create_app(parser=create_parser())

    scheduler.setup(app)
    mqtt.setup(app)
    http.setup(app)
    broadcaster.setup(app)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 5
0
def main():

    app = service.create_app(parser=create_parser())

    scheduler.setup(app)
    mqtt.setup(app)
    relay.setup(app)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 6
0
def main(args=sys.argv):
    if '--cli' in args:
        cli()
        return

    app = service.create_app(default_name='mdns')
    logging.captureWarnings(True)

    dns_discovery.setup(app)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 7
0
def main():
    app = service.create_app(parser=create_parser())
    logging.captureWarnings(True)
    config = app['config']
    app['ini'] = parse_ini(app)

    if getenv('ENABLE_DEBUGGER', False):  # pragma: no cover
        import debugpy
        debugpy.listen(('0.0.0.0', 5678))
        LOGGER.info('Debugger is enabled and listening on 5678')

    if config['simulation']:
        config['device_id'] = config['device_id'] or '123456789012345678901234'
        config['device_host'] = 'localhost'
        config['device_port'] = 8332
        config['device_serial'] = None
        simulator.setup(app)

    service_status.setup(app)
    http.setup(app)

    connection.setup(app)
    commander.setup(app)

    scheduler.setup(app)
    mqtt.setup(app)

    config_store.setup(app)
    block_store.setup(app)
    block_cache.setup(app)
    unit_conversion.setup(app)
    codec.setup(app)
    spark.setup(app)
    broadcaster.setup(app)

    error_response.setup(app)
    debug_api.setup(app)
    blocks_api.setup(app)
    system_api.setup(app)
    settings_api.setup(app)
    mqtt_api.setup(app)

    if config['simulation']:
        sim_api.setup(app)

    synchronization.setup(app)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 8
0
def main():
    app = service.create_app(default_name='simulator')

    # Add implementation-specific functionality
    # In this case: simulator
    simulator.setup(app)

    # Event handling is optional
    # It should be enabled explicitly by service implementations
    events.setup(app)

    # Add all default endpoints
    service.furnish(app)

    # service.run() will start serving clients async
    service.run(app)
Ejemplo n.º 9
0
def main():
    app = service.create_app(parser=create_parser())

    scheduler.setup(app)
    http.setup(app)
    mqtt.setup(app)
    socket_closer.setup(app)
    victoria.setup(app)
    timeseries_api.setup(app)
    redis.setup(app)
    datastore_api.setup(app)
    relays.setup(app)

    app.middlewares.append(controller_error_middleware)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 10
0
def main():
    app = service.create_app(parser=create_parser())

    scheduler.setup(app)
    events.setup(app)
    influx.setup(app)
    query_api.setup(app)
    sse.setup(app)
    relays.setup(app)

    relays.subscribe(app, exchange_name=OLD_EXCHANGE, routing='#')
    relays.subscribe(app,
                     exchange_name=app['config']['broadcast_exchange'],
                     routing='#')

    service.furnish(app)
    service.run(app)
Ejemplo n.º 11
0
def main():
    app = service.create_app(parser=create_parser())

    # Both tiltScanner and event handling requires the task scheduler
    scheduler.setup(app)

    # Initialize event handling
    mqtt.setup(app)

    # Initialize your feature
    tiltScanner.setup(app)

    # Add all default endpoints
    service.furnish(app)

    # service.run() will start serving clients async
    service.run(app)
Ejemplo n.º 12
0
def main():
    app = service.create_app(parser=create_parser())
    logging.captureWarnings(True)
    config = app['config']

    if config['list_devices']:
        LOGGER.info('Listing connected devices: ')
        for dev in [[v for v in p] for p in communication.all_ports()]:
            LOGGER.info(f'>> {" | ".join(dev)}')
        # Exit application
        return

    status.setup(app)
    http_client.setup(app)

    if config['simulation']:
        commander_sim.setup(app)
    else:
        communication.setup(app)
        commander.setup(app)

    scheduler.setup(app)
    events.setup(app)

    couchdb_client.setup(app)
    datastore.setup(app)
    codec.setup(app)
    device.setup(app)
    broadcaster.setup(app)

    error_response.setup(app)
    debug_api.setup(app)
    alias_api.setup(app)
    object_api.setup(app)
    system_api.setup(app)
    remote_api.setup(app)
    codec_api.setup(app)
    sse_api.setup(app)

    seeder.setup(app)

    service.furnish(app)
    service.run(app)
Ejemplo n.º 13
0
def main():

    app = service.create_app(parser=create_parser())

    # Enable the task scheduler
    # This is required for the `events` feature,
    # and for the RepeaterFeature used in poll_example
    scheduler.setup(app)

    # Enable event handling
    # Event subscription / publishing will be enabled after you call this function
    events.setup(app)

    # Enable making HTTP requests
    # This allows you to access a shared aiohttp ClientSession
    # https://docs.aiohttp.org/en/stable/client_reference.html
    http.setup(app)

    # To keep everything consistent, examples also have the setup() function
    # In here they register everything that must be done before the service starts
    # It's not required to use this pattern, but it makes code easier to understand
    events_example.setup(app)
    poll_example.setup(app)
    http_example.setup(app)

    # Add all default endpoints, and adds prefix to all endpoints
    #
    # Default endpoints are:
    # {prefix}/api/doc (Swagger documentation of endpoints)
    # {prefix}/_service/status (Health check: this endpoint is called to check service status)
    #
    # The prefix is automatically added for all endpoints. You don't have to do anything for this.
    # To change the prefix, you can use the --name command line argument.
    #
    # See brewblox_service.service for more details on how arguments are parsed.
    #
    # The default value is "YOUR_PACKAGE" (provided in service.create_app()).
    # This means you can now access the example/endpoint as "/YOUR_PACKAGE/example/endpoint"
    service.furnish(app)

    # service.run() will start serving clients async
    service.run(app)
Ejemplo n.º 14
0
def main():
    app = service.create_app(default_name='history')

    # Setup history functionality
    events.setup(app)
    influx.setup(app)

    # Add all default endpoints and add prefix
    #
    # Default endpoints are:
    # {prefix}/api/doc (Swagger documentation of endpoints)
    # {prefix}/_service/status (Health check: this endpoint is called to check service status)
    #
    # The prefix is automatically added for all endpoints. You don't have to do anything for this.
    # To change the prefix, you can use the --name command line argument.
    #
    # See brewblox_service.service for more details on how arguments are parsed.
    #
    # The default value is "brewblox".
    # This means you can now access the example/endpoint as "/brewblox/example/endpoint"
    service.furnish(app)

    # service.run() will start serving clients async
    service.run(app)
Ejemplo n.º 15
0
def app(sys_args):
    app = service.create_app('default', raw_args=sys_args[1:])
    return app
Ejemplo n.º 16
0
def list_device_app(sys_args):
    sys_args.append('--list-devices')
    parser = main.create_parser('default')
    app = service.create_app(parser=parser, raw_args=sys_args[1:])
    return app
Ejemplo n.º 17
0
def app(sys_args, app_ini):
    parser = create_parser('default')
    app = service.create_app(parser=parser, raw_args=sys_args[1:])
    app['ini'] = app_ini
    return app
Ejemplo n.º 18
0
def app(sys_args):
    parser = create_parser('default')
    app = service.create_app(parser=parser, raw_args=sys_args[1:])
    app.middlewares.append(controller_error_middleware)
    return app
Ejemplo n.º 19
0
def app(sys_args):
    parser = create_parser('default')
    app = service.create_app(parser=parser, raw_args=sys_args[1:])
    return app
Ejemplo n.º 20
0
def app(sys_args):
    app = service.create_app(default_name='mdns_test', raw_args=sys_args[1:])
    return app
Ejemplo n.º 21
0
def test_create_app(sys_args, app_config, mocker):
    app = service.create_app(default_name='brewblox', raw_args=sys_args[1:])

    assert app is not None
    assert app['config'] == app_config