Exemplo n.º 1
0
def start_camera_worker(host,
                        port,
                        scripts_base,
                        hostname=None,
                        port_range=None,
                        mode=0,
                        web_server=config.DEFAULT_WEB_SERVER,
                        web_server_args={}):

    if hostname:
        _logger.warning("Using custom hostname '%s'." % hostname)

    config_manager = CameraConfigManager(config_provider=TransientConfig())
    user_scripts_manager = UserScriptsManager(scripts_base)
    camera_instance_manager = CameraInstanceManager(config_manager,
                                                    user_scripts_manager,
                                                    hostname=hostname,
                                                    port_range=port_range,
                                                    mode=mode)

    app = bottle.Bottle()

    register_camera_rest_interface(app=app,
                                   instance_manager=camera_instance_manager)

    try:
        bottle.run(app=app,
                   server=validate_web_server(web_server),
                   host=host,
                   port=port,
                   **web_server_args)
    finally:
        # Close the external processor when terminating the web server.
        camera_instance_manager.stop_all_instances()
def start_camera_server(host, port, config_base, hostname=None):

    # Check if config directory exists
    if not os.path.isdir(config_base):
        _logger.error("Configuration directory '%s' does not exist." %
                      config_base)
        exit(-1)

    if hostname:
        _logger.warning("Using custom hostname '%s'." % hostname)

    config_manager = CameraConfigManager(
        config_provider=ConfigFileStorage(config_base))
    camera_instance_manager = CameraInstanceManager(config_manager,
                                                    hostname=hostname)

    app = bottle.Bottle()

    register_camera_rest_interface(app=app,
                                   instance_manager=camera_instance_manager)

    try:
        bottle.run(app=app, host=host, port=port)
    finally:
        # Close the external processor when terminating the web server.
        camera_instance_manager.stop_all_instances()
    def test_custom_hostname(self):
        config_manager = CameraConfigManager(
            config_provider=MockConfigStorage())
        camera_instance_manager = CameraInstanceManager(
            config_manager, None, hostname="custom_cam_hostname")
        config_manager.save_camera_config(
            "simulation",
            CameraConfig("simulation").get_configuration())

        stream_address = camera_instance_manager.get_instance_stream(
            "simulation")
        self.assertTrue(stream_address.startswith("tcp://custom_cam_hostname"))

        camera_instance_manager.stop_all_instances()
def start_camera_server(host,
                        port,
                        config_base,
                        scripts_base,
                        hostname=None,
                        port_range=None,
                        mode=0,
                        web_server=config.DEFAULT_WEB_SERVER,
                        web_server_args={}):

    # Check if config directory exists
    if not os.path.isdir(config_base):
        _logger.error("Configuration directory '%s' does not exist." %
                      config_base)
        exit(-1)

    if hostname:
        _logger.warning("Using custom hostname '%s'." % hostname)

    config_manager = CameraConfigManager(
        config_provider=ConfigFileStorage(config_base))
    user_scripts_manager = UserScriptsManager(scripts_base)
    camera_instance_manager = CameraInstanceManager(config_manager,
                                                    user_scripts_manager,
                                                    hostname=hostname,
                                                    port_range=port_range,
                                                    mode=mode)

    app = bottle.Bottle()

    register_camera_rest_interface(app=app,
                                   instance_manager=camera_instance_manager)

    try:
        bottle.run(app=app,
                   server=validate_web_server(web_server),
                   host=host,
                   port=port,
                   **web_server_args)
    finally:
        # Close the external processor when terminating the web server.
        camera_instance_manager.stop_all_instances()
Exemplo n.º 5
0
def get_test_instance_manager():
    config_manager = CameraConfigManager(config_provider=MockConfigStorage())
    camera_instance_manager = CameraInstanceManager(config_manager, None)

    return camera_instance_manager