rpymostat.config module

class rpymostat.config.Config[source]

Bases: object

RPyMostat configuration. Reads configuration from environmnet variables, sets defaults for anything missing.

_config_vars = {'mongo_port': {'default_value': 27017, 'is_int': True, 'description': 'port number to connect to MongoDB at', 'env_var_name': 'MONGODB_PORT'}, 'api_port': {'default_value': 8088, 'is_int': True, 'description': 'port number to run API server on', 'env_var_name': 'API_PORT'}, 'verbose': {'default_value': 0, 'is_int': True, 'description': 'log verbosity; set to 0 for warning, 1 for info or 2 for debug', 'env_var_name': 'VERBOSE'}, 'mongo_host': {'default_value': 'localhost', 'is_int': False, 'description': 'host/IP to connect to MongoDB at', 'env_var_name': 'MONGODB_HOST'}}
_get_from_env()[source]

Build self._config from env vars and defaults (self._config_vars).

Returns:effective configuration dict
as_dict

Return the full configuration dictionary, setting names to values.

Returns:configuration dict
Return type:dict
get(setting_name)[source]

Return the effective value for the configuration option setting_name

Parameters:setting_name (str) – the config setting to get
Returns:str or int configuration value
get_var_info()[source]

Return information about configuration variables. Returns a dict keyed by setting name. Values are dicts with keys:

  • env_var_name - environment variable name for this setting
  • description - description of this variable
  • is_int - boolean, whether the value should be an int or a str
  • default_value - default value if not present in os.environ
Returns:dict describing configuration variables
Return type:dict