pyrolab.configure.GlobalConfiguration#
- class GlobalConfiguration[source]#
Bases:
objectA Singleton global configuration object that can read and write configuration files.
Warning
The GlobalConfiguration should only be accessed by MainProcess threads. Any spawned or forked processes should simply load the
RUNTIME_CONFIGusing the PyroLabConfiguration parser.PyroLab configurations are stored in a YAML file. This class provides a singleton object that can be used to read and write the configuration file. The YAML files contain three sections:
nameservers,daemons, andservices. See the documentation for examples of valid YAML files.The user configuration file is stored in
pyrolab.configure.USER_CONFIG_FILE. PyroLab instances maintain the configuration state of the file when the program was launched; in other words, if the file is updated, the configuration state of running instances is not modified by default. There are features and switches to turn on autoreload, however; see the documentation.To ensure all processes have access to the same configuration, the configuration of an active instance is locked to a single file separate from where user-defined configuration files are stored. This class is a singleton; only the main process can modify the configuration. All spawned child processes will use the configuration from the locked file.
- Attributes:
- config: PyroLabConfiguration
Methods
Clears all configuration data without reloading built-in defaults.
Returns the global configuration.
get_daemon_config(daemon)Returns the configuration for the given daemon.
get_nameserver_config(nameserver)Returns the configuration for the given nameserver.
get_service_config(service)Returns the configuration for the given service.
get_service_configs_for_daemon(daemon)Returns the services for the given daemon.
instance()Returns the singleton instance of the GlobalConfiguration class.
load_config(filename)Reads the configuration file and updates the internal configuration.
save_config(filename)Persists the configuration to a file.
set_config(cfg)Sets the global configuration to the given configuration.