def get_config_directory(configs):
    agg = AggregateConfig(configs=configs)

    for key in agg.keys():
        if key not in ['CurrencyHome', 'ConfigDirectory']:
            del agg[key]

    return agg.resolve({'home': 'CurrencyHome'})['ConfigDirectory']
def get_config_directory(configs):
    agg = AggregateConfig(configs=configs)

    for key in agg.keys():
        if key not in ['CurrencyHome', 'ConfigDirectory']:
            del agg[key]

    return agg.resolve({'home': 'CurrencyHome'})['ConfigDirectory']
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=None):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [
        conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    # Require the config files unless it is an empty list or the
    # default of txnvalidator.js.
    if config_files_required is None:
        config_files_required = len(config_files) != 0 and \
            not (len(config_files) == 1 and
                 config_files[0] == 'txnvalidator.js')

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=None):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    # Require the config files unless it is an empty list or the
    # default of txnvalidator.js.
    if config_files_required is None:
        config_files_required = len(config_files) != 0 and \
            not (len(config_files) == 1 and
                 config_files[0] == 'txnvalidator.js')

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
def get_mktplace_configuration(config_files,
                               options_config,
                               os_name=os.name,
                               config_files_required=True):
    env_config = MarketPlaceEnvConfig()

    default_config = MarketPlaceDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    user_conf_dir = os.path.join(os.path.expanduser("~"), ".sawtooth")

    # Determine the configuration file search path
    search_path = [
        conf_dir, user_conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'name': 'ParticipantName',
        'user': '******',
        'user_conf_dir': 'UserConfigDirectory'
    })
    return resolved
def get_mktplace_configuration(config_files,
                               options_config,
                               os_name=os.name,
                               config_files_required=True):
    env_config = MarketPlaceEnvConfig()

    default_config = MarketPlaceDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    user_conf_dir = os.path.join(os.path.expanduser("~"), ".sawtooth")

    # Determine the configuration file search path
    search_path = [conf_dir, user_conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'name': 'ParticipantName',
        'user': '******',
        'user_conf_dir': 'UserConfigDirectory'
    })
    return resolved
Beispiel #7
0
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=True):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [
        conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=True):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    # Determine the configuration file search path
    search_path = [conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory'
    })
    return resolved