Пример #1
0
def set_host(url_):
    hosts = get('host', 'auth')
    if url_ in [host_['url'] for host_ in hosts]:
        _config['host']['selected'] = url_
    else:
        raise errors.ConfigError("There is no host with url {}".format(url_))

    _persist()
Пример #2
0
def _get_selected_host_auth():
    selected = get('host', 'selected')
    hosts = get('host', 'auth')
    for host_ in hosts:
        if host_['url'] == selected:
            return host_

    raise errors.ConfigError("The selected host doesn't exist.")
Пример #3
0
def get(*args):
    try:
        prop = _config
        for at in list(args):
            prop = prop[at]
        return prop
    except KeyError as e:
        raise errors.ConfigError('missing property: {}'.format(_key_error_string(e)))
Пример #4
0
def username():
    try:
        return _get_selected_host_auth()['username']
    except KeyError as e:
        raise errors.ConfigError('missing property: {}'.format(
            _key_error_string(e)))