Example #1
0
def parse_proxy_address(value):
    result = None
    match = proxy_regex.match(value)
    if match:
        # Ignoring the protocol part for now as it is only a http proxy
        result = HTTPProxyConfig(host=match.group('host'),
                                 port=int(match.group('port')))
    elif value:
        # In this case something was provided that isn't a falsy value but the parsing failed.
        raise ConfigurationError(ERR_CONF_PROXY_CONF_VALUE.format(value=value))
    return result
Example #2
0
    def __init__(self, config, local_config, backend=None):
        self.config = local_config

        if backend is not None:
            if self.backend is not None:
                raise ConfigurationError(
                    ERR_CONF_ONE_BACKEND_ONLY.format(
                        backend1=self.backend,
                        backend2=backend
                    )
                )
            else:
                ConfigurableComponent._backend = backend
        elif self.backend is not None:
            # Register configurator instance
            self.backend.register_configurator(self)
Example #3
0
 def _crosscheck_ws_server_uri(self, listen, legacy=False):
     """
     Checking for sockets already listening on the specified listen address. If there is a server there
     its factory is returned, if there isn't one, None is returned, if there is protocol mismatch
     a ConfigurationError exception is raised.
     :param listen: URI of websocket server
     :return: BroadcastServerFactory instance if exists for listen address, otherwise None
     :raises ConfigurationError: on protocol mismatch
     """
     ws_server = self._ws_twisted_servers.get(listen)
     wsl_server = self._wsl_twisted_servers.get(listen)
     if ws_server and legacy or wsl_server and not legacy:
         raise ConfigurationError(
             ERR_CONF_WS_SERVER_PROTOCOL_MISMATCH.format(address=listen))
     if ws_server:
         return ws_server
     if wsl_server:
         return wsl_server
     return None
Example #4
0
def get_backend(backend_name):
    try:
        return backend_by_type.get(backend_name)
    except KeyError:
        raise ConfigurationError(
            ERR_NO_SUCH_COMPONENT.format(type_name=backend_name))
Example #5
0
def get_consumer_carriage(carriage_type):
    try:
        return consumer_carriage_by_type[carriage_type]
    except KeyError:
        raise ConfigurationError(
            ERR_NO_SUCH_COMPONENT.format(type_name=carriage_type))
Example #6
0
def get_node(node_type):
    try:
        return nodes_by_type[node_type]
    except KeyError:
        raise ConfigurationError(
            ERR_CONF_NO_SUCH_NODE.format(node_type=node_type))
Example #7
0
def get_clock(clock_type):
    try:
        return clock_by_type[clock_type]
    except KeyError:
        raise ConfigurationError(
            ERR_NO_SUCH_COMPONENT.format(type_name=clock_type))