Exemple #1
0
def test_channel_config_dir(tmp_path, monkeypatch):
    channel_cfg_dir = tmp_path / 'config.d'
    absolute_parent_path = str(channel_cfg_dir.parent.resolve())
    channel_cfg_dir.mkdir()

    # Explicit parent path
    channel_config_dir = policies.channel_config_dir(absolute_parent_path)
    assert channel_cfg_dir == channel_config_dir

    # Through channel-config environment variable
    with monkeypatch.context() as m:
        m.setenv('CHANNEL_CONFIG_PATH', str(channel_cfg_dir))
        channel_config_dir = policies.channel_config_dir()
        assert channel_cfg_dir == channel_config_dir

    # Through global-config environment variable
    with monkeypatch.context() as m:
        m.setenv('CONFIG_PATH', absolute_parent_path)
        channel_config_dir = policies.channel_config_dir()
        assert channel_cfg_dir == channel_config_dir
Exemple #2
0
def main(args=None):
    '''
    If args is None, sys.argv will be used instead
    If args is a list, it will be used instead of sys.argv (for unit testing)
    '''
    options = parse_program_options(args)
    global_config_dir = policies.global_config_dir()
    global_config, channel_config_loader = _get_de_conf_manager(
        global_config_dir, policies.channel_config_dir(), options)
    try:
        _start_de_server(global_config, channel_config_loader)
    except Exception as e:  # pragma: no cover
        msg = f"""Config Dir: {global_config_dir}
              Fatal Error: {e}"""
        print(msg, file=sys.stderr)
        sys.exit(msg)
def main(args=None):
    '''
    If args is None, sys.argv will be used instead
    If args is a list, it will be used instead of sys.argv (for unit testing)
    '''
    options = parse_program_options(args)
    global_config_dir = policies.global_config_dir()
    global_config, channel_config_loader = _get_de_conf_manager(global_config_dir,
                                                                policies.channel_config_dir(),
                                                                options)
    try:
        _start_de_server(global_config, channel_config_loader)
    except Exception as e:
        sys.exit("Server Address: {}\n".format(global_config.get('server_address')) +
                 "Config Dir: {}\n".format(global_config_dir) +
                 "Fatal Error: {}\n".format(e))