示例#1
0
def load_configs(configuration_files):
    v.automatic_env()
    v.set_env_key_replacer(".", "_")
    v.set_config_type("yaml")
    v.add_config_path("./resources/configurations")

    for configuration_file in configuration_files:
        v.set_config_name(configuration_file)
        v.merge_in_config()
示例#2
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."
        )
示例#3
0
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
示例#4
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()
示例#6
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
示例#7
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"))
示例#9
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()
示例#10
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)
示例#11
0
INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'taggit',
    'account',
    'code_metadata',
    'dataset',
    'problem',
    'competition',
]

AUTH_USER_MODEL = 'account.User'

# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

TAGGIT_CASE_INSENSITIVE = True

if 'CONFIG_DIR' in environ:
    v.add_config_path(environ['CONFIG_DIR'])
v.add_config_path('configs')
v.add_config_path('/configs')
v.watch_config()

v.automatic_env()
v.set_env_prefix('roboepics')
示例#12
0
def init_config():
    v.set_config_name('compton')
    v.add_config_path('/etc/compton')
    v.add_config_path('$HOME/.compton')
    v.add_config_path('.')
示例#13
0
"""Plex script that allows the plex owner to make requests to their PMS."""
import json
import webbrowser
from time import sleep

import requests
from vyper import v

v.set_config_name("config")
v.add_config_path('.')
v.read_in_config()


class Plex:
    """The Plex Class which allows for the script to make requests to the PMS"""
    # todo: create UUID dynamically each time script runs
    plex_client_id = "2a4290e1-6613-4b81-8811-13194c023f49"  # Random UUID
    plex_token = None

    def __init__(self, config: dict, BASE_URL):
        self.config = config
        self.port = config.get('port', None)

        self.base_url = BASE_URL

    def get_pms_token(self):
        """A method to request a PMS token. Open up an authorization webpage then verify user allowed access. Once
        authorized, the plex token is then written in a JSON file for persistence."""
        _id = None
        validated = False
        url = "https://plex.tv/api/v2/pins"
示例#14
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()
示例#15
0
def get_config():
	v.set_config_name('ocpperf')
	v.add_config_path('.')
	v.read_in_config()
	return v