Mercury2 Hardware Manager  1.0dev
The hardware manager component of the Mercury2 ground station suite.
 All Classes Namespaces Functions Variables Pages
hwm.core.configuration.Config Class Reference

Provides access to the hardware manager application configuration. More...

Public Member Functions

def __init__
 Initializes the Config class with some initial static configuration.
 
def read_configuration
 Loads and parses the specified configuration file. More...
 
def set
 Sets the indicated configuration option to the provided value. More...
 
def get
 Retrieves the specified configuration option. More...
 
def delete
 Removes the specified configuration option from the user options dictionary. More...
 
def validate_configuration
 Verifies that the loaded configuration conforms to the schema. More...
 

Public Attributes

 version
 
 verbose_startup
 
 options
 
 user_options
 
 config_directory
 
 data_directory
 
 log_directory
 

Private Member Functions

def _process_defaults
 Copies the default values from the configuration schema to the options dictionary. More...
 
def _set_hwm_directories
 Sets the location of the Mercury2 HWM configuration and data directories. More...
 

Detailed Description

Provides access to the hardware manager application configuration.

This class stores and provides access to the configuration and various shared state used by the hardware manager. In addition, it allows users to store their own configuration options as needed. To use this class, import this module (configuration) and assign a local variable to 'Configuration' (makes code easier to test).

Note
Although this class does store raw pipeline and hardware configuration settings (defined in the configuration files), all interactions with the pipelines and hardware occur in the PipelineManager and DeviceManager classes, respectively.
Only user_options can be modified during program execution (using the setter/getter). This prevents configuration options specified in a file from getting altered/deleted.

Member Function Documentation

def hwm.core.configuration.Config._process_defaults (   self,
  configuration_schema 
)
private

Copies the default values from the configuration schema to the options dictionary.

 This method copies the default values for unspecified options from the defined configuration schema to the options
 dictionary.
Note
The JSON schema validation class does not currently provide this functionality, so it must be done using this method.
See Also
https://github.com/Julian/jsonschema/issues/4
Parameters
configuration_schemaA dictionary containing the configuration schema to use when copying default values.
def hwm.core.configuration.Config._set_hwm_directories (   self)
private

Sets the location of the Mercury2 HWM configuration and data directories.

This method sets the locations of the various Mercury2 configuration and data directories, which contain the HWM configuration files, logs, and telemetry dumps, among other things.

def hwm.core.configuration.Config.delete (   self,
  option_key 
)

Removes the specified configuration option from the user options dictionary.

Note
Only user defined configuration options can be removed.
Exceptions
OptionProtectedthrown if the user tries to delete a protected option (originally defined in a YAML configuration file).
OptionNotFoundthrown if the requested option can't be located.
Parameters
option_keyThe key of the option to remove.
Returns
Returns True if the option was successfully deleted.
def hwm.core.configuration.Config.get (   self,
  option_key 
)

Retrieves the specified configuration option.

 This method returns the value of the specified option whether it is a user defined option or an option loaded from 
 a YAML configuration file.
Exceptions
OptionNotFoundThrown if the specified option can't be located.
Parameters
option_keyThe key of the option to query for.
Returns
Returns the value of the specified option if it exists.
def hwm.core.configuration.Config.read_configuration (   self,
  configuration_file 
)

Loads and parses the specified configuration file.

 Reads in all configuration settings from the specified YAML file and stores them in the 'options' dictionary.
Exceptions
IOErrorThrown if the specified file can't be loaded.
ConfigFileMalformedThrown if the specified file can't be parsed by the YAML parser.
Note
All configuration files are in YAML format.
All configuration files are assumed to be required (i.e. this throws an exception if the file can't be loaded).
If a file is loaded that contains a previously defined protected option, the previous value will be overridden by the new value.
See Also
http://en.wikipedia.org/wiki/YAML
Parameters
configuration_fileThe YAML configuration file to load. This is an absolute path.
def hwm.core.configuration.Config.set (   self,
  option_key,
  option_value 
)

Sets the indicated configuration option to the provided value.

Exceptions
OptionProtectedthrown if the user tries to modify or set a protected run-time option.
Parameters
option_keyThe key (name) of the option to set.
option_valueThe value to assign to the indicated option.
Returns
Returns True if the option was successfully set.
def hwm.core.configuration.Config.validate_configuration (   self)

Verifies that the loaded configuration conforms to the schema.

 This method compares the currently loaded configuration settings against the defined configuration schema. This 
 ensures that all required options have been set and that they meet formatting requirements.
Note
All configuration files that contain methods defined in this schema must be loaded before this method is called.
In the schema, all required options that have an associated default value must have "required" set to False, otherwise the schema validation will fail when it should just use the default value.
Exceptions
Maythrow ConfigInvalid if the loaded configuration set does not conform to the schema.

The documentation for this class was generated from the following file: