Пример #1
0
def load_configuration():
    config_loader = ConfigLoader()
    config_loader.update_from(obj=config_loader, yaml_env='CONFIG_FILE_PATH')
    config_loader.update_from_env_namespace('')
    return config_loader
Пример #2
0
import connectordb
import requests.exceptions
from configloader import ConfigLoader

CONFFILE = os.getenv("HOME") + '/.tickmate-connectordb.yaml'
TESTCONFFILE = './test-resources/tickmate-connectordb.yaml'

MAIN_CONF = CONFFILE

config = ConfigLoader()
if os.path.isfile(CONFFILE):
    config.update_from_yaml_file(os.path.normpath(CONFFILE))
if os.path.isfile(TESTCONFFILE):
    MAIN_CONF = TESTCONFFILE
    config.update_from_yaml_file(os.path.normpath(TESTCONFFILE))
config.update_from_env_namespace(namespace='TKCDB')


def trackname_to_streamname(name):
    return name.replace("/", "").replace("-", "").title().replace(" ", "")


def get_cdb_device(url, name):
    try:
        if url is None:
            url = config.get('URL')
        api_key = config.get('API_KEY')
        if api_key is None:
            import setup_device
            url, api_key = setup_device.setup_device(MAIN_CONF, config, url,
                                                     name)