示例#1
0
文件: Config.py 项目: wolf637/skytap
    # for most things you'd want to do.
    config_data = INITIAL_CONFIG

# Load config values and set up the class.

for key in Config:
    env_val = "SKYTAP_" + key.upper()
    if env_val in os.environ:
        Config.config_data[key] = os.environ[env_val]
        try:
            Config.config_data[key] = int(Config.config_data[key])
        except ValueError:
            pass

if os.environ.get('READTHEDOCS', None) != 'True':
    if Config.base_url != 'https://cloud.skytap.com':
        Utils.warning('Base URL is not Skytap\'s recommended value. ' +
                      'This very likely will break things.')

    if len(Config.token) == 0:
        Utils.error('No environment variable SKYTAP_TOKEN found. ' +
                    'Set this variable and try again.')
        raise ValueError

    if len(Config.user) == 0:
        Utils.error('No environment variable SKYTAP_USER found. ' +
                    'Set this variable and try again.')
        raise ValueError

Utils.log_level(Config.log_level)
示例#2
0
def test_config_value_doesnt_exist():
    """Test that an invalid config request raises an AttributeError."""
    log_lvl = Utils.log_level()
    Utils.log_level(50)
    place_holder = Config.this_value_should_not_exist
    Utils.log_level(log_lvl)