Beispiel #1
0
def find_config_file():
    v.set_config_name(default.CONFIG_FILENAME)
    for supported_path in default.SUPPORTED_CONFIG_PATHS:
        v.add_config_path(supported_path)
    try:
        v.read_in_config()
    except Exception:
        log.warning(
            "No configuration file was found. "
            "Some tweaks may be missing or were provided through environment variables."
        )
def vyper_config():
    # not yet sure if we want to have elasticsearch config file override option
    # env = Env()
    # env.read_env()
    # if os.getenv('OCPPERF_SERVER_CONFIG') is not None:
    # 	env.str(
    # 		'OCPPERF_SERVER_CONFIG',
    # 		validate=Length(min=1),
    # 		subset=Optional
    # 	)
    v.set_config_name('ocpperf')
    v.add_config_path('.')
    v.read_in_config()
    return v
Beispiel #3
0
def setup_vyper(parser):
    env_name = os.getenv("APP_ENV_NAME", "LOCAL").lower()
    config_name = "config.{}".format(env_name)

    v.bind_args(parser)

    v.set_env_prefix(v.get("environment_variables_prefix"))
    v.set_env_key_replacer("-", "_")
    v.automatic_env()

    v.add_config_path("config")
    v.set_config_type("toml")
    v.set_config_name(config_name)
    v.read_in_config()
def setup_vyper(parser, overrides):
    defaults = _get_default_args(parser)

    actual_overrides = \
        {k: val for k, val in overrides.items() if defaults[k] != val}
    env_name = os.getenv("APP_ENV_NAME", "LOCAL").lower()
    config_name = "config.{}".format(env_name)

    _setup_args(parser)
    _setup_overrides(actual_overrides)

    v.set_env_prefix(v.get("env_vars_prefix"))
    v.automatic_env()

    v.add_config_path("config")
    v.set_config_type("toml")
    v.set_config_name(config_name)
    v.read_in_config()
Beispiel #5
0
def pytest_configure(config):
    """
    Performs loading of json-formatted config and extracts vyper object to pytest context variable 'config'

    The config can be loaded from consul server if consul-url, consul-token, consul-path provided,
        seeks for config at {consul-url/consul-path/env}

    If consul-url is not specified, reads config files stored at {test-rootdir/config/env.json}

    """
    config_type = 'json'
    env = config.option.env

    v.set_config_type(config_type)

    is_remote = bool(config.option.consul_url)

    if is_remote:
        c = urlparse(config.option.consul_url)

        token = config.option.consul_token
        client = consul.Consul(host=c.hostname,
                               port=c.port,
                               scheme=c.scheme,
                               token=token)
        path = f'{config.option.consul_path}/{env}'
        provider = 'consul'

        v.add_remote_provider(provider, client, path)
        v.read_remote_config()
    else:
        path = f'{config.rootdir.strpath}/config'

        v.set_config_name(config.option.env)
        v.add_config_path(path)

        try:
            v.read_in_config()
        except FileNotFoundError:
            raise FileNotFoundError(
                f'File not found: {path}/{env}.{config_type}')

    config.v = v
Beispiel #6
0
def setup_vyper(parser: argparse.ArgumentParser,
                overrides: Dict[str, Any] = None):
    env_name = os.getenv("APP_ENV_NAME", "LOCAL").lower()
    config_name = "config.{}".format(env_name)

    v.bind_args(parser)

    if overrides:
        for k, val in overrides.items():
            v.set(k, val)

    v.set_env_prefix(v.get("environment_variables_prefix"))
    v.set_env_key_replacer("-", "_")
    v.automatic_env()

    v.add_config_path("config")
    v.set_config_type("toml")
    v.set_config_name(config_name)
    v.read_in_config()
def get_config() -> Config:
    v.set_config_name("pruner_config")
    v.add_config_path(".")
    v.read_in_config()
    return Config(prune_configs=v.get("pruner"))
Beispiel #8
0
def pytest_configure(config):
    env = config.getoption('--env')
    configuration.set_config_name(env)
    configuration.set_config_type('yaml')
    configuration.add_config_path('./config')
    configuration.read_in_config()
Beispiel #9
0
from flask import Flask
from vyper import v

app = Flask(__name__)


def update_config():
    """Updates Flask's config."""
    return app.config.update(v.all_settings(uppercase_keys=True))


v.add_config_path(".")
v.set_config_type("json")
v.read_in_config()
update_config()
v.watch_config()
v.on_config_change(update_config)


@app.route("/")
def hello():
    return "Hello " + app.config["HELLO"]


if __name__ == "__main__":
    app.run(use_reloader=False)
Beispiel #10
0
def read_config():
    v.read_in_config()
Beispiel #11
0
def init_config():
    v.set_config_name('correly')
    v.add_config_path('/etc/correly/')
    v.add_config_path('$HOME/.correly')
    v.add_config_path('.')
    v.read_in_config()
Beispiel #12
0
def get_config():
	v.set_config_name('ocpperf')
	v.add_config_path('.')
	v.read_in_config()
	return v