Configuration component.
Provides access to configuration options read from ApplicationContext.appEnvironment.options (command-line options), user configuration file and system configuration file. For that purpose it provides ConfigurationBase implementation via ConfigurationFactory. Configuration should be created centrally by some common component and that instance distributed to other components. Individual components should not call ConfigurationFactory directly.
For more information about ConfigurationBase provided interface see ConfigurationFactory.
ConfigurationBase class.
Bases: builtins.object
Provides access to configuration options.
Gets the raw value of a configuration option or None.
Unlike the __getitem__() this method returns the real raw value of the option.
Parameters: | option (Option) – The option for which the value should be returned. |
---|---|
Returns: | The raw value of the passed option (can be None). |
Return type: | object |
Raises KeyError: | |
If option does not exists. |
Options, OptionsUtils and SpecialOptionTypes static classes. Option class and ArchiverTypes enum.
Bases: builtins.object
Constants for configuration options.
These constants should be used to access options in the IConfiguration implementation provided by the Configuration component.
Note
It is not allowed to change values of these constants.
Operate on all configured archive specification files.
Archiver type. Guaranteed to be defined.
Directory where archive specification files will be searched. Guaranteed to be defined.
Arbitrary command to executes after the backup creation.
Arbitrary command to execute prior to the backup creation.
Compression strength level.
Directory where the backup will be created. Guaranteed to be defined.
Force archiver type regardless to what is specified in the archive specification file.
Force compression level regardless to what is specified in the archive specification file.
Force the directory where the backup will be created.
Force incremental backup regardless to what is specified in the archive specification file.
Force the backup level restarting regardless to what is specified in the archive specification file.
Number of days after which the backup level is restarted to 0.
Number of backup level restarts after which the level is restarted to 0.
Incremental backup.
Turn on backup keeping. When a backup is about to be overwritten, it is renamed instead.
Backup level used in incremental archiving.
Maximal percentage size of a backup (of level > 0) to which level is allowed restart to. The size is percentage of size of the level 0 backup file. If a backup of particular level has its size bigger than defined percentage, restart to that level will not be allowed.
Do not operate on all configured archive specification files.
Disable incremental backup.
Turn off backup keeping.
Turn off backup level restarting.
Number of old backups to keep when KEEP_OLD_BACKUPS is enabled. Guaranteed to be defined.
Turn on quiet output. Only errors will be shown. If QUIET is turned on at the same level as VERBOSE (e. g. both are specified on the command line) then QUIET has higher priority than VERBOSE.
Turn on removing backups of levels that are no longer valid due to the backup level restart. All backups of the backup level higher than the one currently being created will be removed.
Turn on backup level restarting.
Number of days after which the backup level is restarted. Similarly to RESTART_AFTER_LEVEL it will be restarted to level 1 or higher.
Maximal backup level. If reached, it will be restarted back to a lower level (which is typically level 1 but it depends on MAX_RESTART_LEVEL_SIZE). Guaranteed to be defined.
User configuration directory. Guaranteed to be defined.
User configuration file. Guaranteed to be defined.
Turn on verbose output.
Bases: builtins.object
Various utility methods working with Options.
Converts ArchiverTypes to string representation.
Value of the archiverType parameter is converted to a string representation that is accepted by the strToOptionType() method.
Parameters: | archiverType (ArchiverTypes) – Archiver type that shall be converted. |
---|---|
Returns: | String form of passed archiverType. |
Return type: | str |
Raises ValueError: | |
If archiverType is not known. |
Iterator over all known options.
Returns: | All options defined in Options. |
---|---|
Return type: | Iterator<Option> |
Iterator over all known special option types.
Returns: | All option types defined in SpecialOptionTypes. |
---|---|
Return type: | Iterator<str> |
Return option with given name.
Parameters: | optionName (str) – Name of the option that shall be returned. |
---|---|
Returns: | First option from getAllOptions() which name is optionName. |
Return type: | Option |
Raises KeyError: | |
If option with name optionName does not exist. |
Check whether an option with name optionName does exists in OptionsUtils.
Parameters: | optionName (str) – Name of the option which existence shall be checked. |
---|---|
Returns: | True if option with name optionName exists; False otherwise. |
Return type: | bool |
Converts string option value to its proper, defined type.
Parameters: |
|
---|---|
Returns: | Converted optionValue. |
Return type: | object |
Raises: |
|
Returns force form for option or None.
Parameters: | option (Option) – An option in the normal form for which the force form for shall be returned. |
---|---|
Returns: | Force form of the passed option or None if it does not have a force form. |
Return type: | Option |
Returns negation form for option or None.
Parameters: | option (Option) – An option in the normal form for which the negation form for shall be returned. |
---|---|
Returns: | Negation form of the passed option or None if it does not have a negation form. |
Return type: | Option |
Bases: builtins.object
Represents a configuration option.
Parameters: |
|
---|
Bases: builtins.object
Constants for special option types.
Normally, options are of some standard type, such as int, str, etc. Some of them however, requires special handling for which the special option types are defined in this class.
Note
It is not allowed to change values of these constants.
A filesystem path.
Archiver types.
ConfigurationFactory class.
Bases: builtins.object
Support of configuration options and a persistent storage.
During makeConfiguration() call it creates IConfiguration implementation instance. It also creates user configuration directory and archive specifications directory if either of them does not exists.
The ConfigurationBase-like class provides access to configuration options. It is instantiated and populated during makeConfiguration() call from ApplicationContext.appEnvironment.options (command-line options) and from configuration files. The system configuration file is “/etc/aa/aa.conf”. The user configuration file location is determined by values of Options.USER_CONFIG_FILE and Options.USER_CONFIG_DIR options. The user configuration directory is automatically created if it does not exists. The format of configuration files is defined by the standard configparser module (without interpolation).
The ConfigurationBase implementation instance is populated in the way that same options specified in multiple sources overrides each other so that the order of precedence from highest to lowest is following: command-line, user configuration file, system configuration file. However the implementation recognizes certain types of options that does not follow this rule (see ConfigurationBase.__getitem__()).
Some of the options, if not specified in neither of possible sources, has some predefined default value. The list of these options with their predefined value follows:
Creates and populates configuration.
Parameters: | appEnvironment (AppEnvironment) – Application environment. |
---|
_Configuration class.
Bases: AutoArchive._infrastructure.configuration.configuration_base.ConfigurationBase
Application’s configuration.
Provides access to application’s configuration. All configuration options that can be accessed via this class are defined as static attributes of Options.
After construction, all options are added and initialized to None. It is expected that concrete values will be added using the _addOrReplaceOption() method.
Adds an option and its value replacing the value if already exists.
String representation of the value is expected. It will be converted to a proper type defined by the option.
Parameters: |
|
---|---|
Raises: |
|
_CmdlineArgumentsProcessor class.
Bases: builtins.object
Processes command-line arguments and populates IConfiguration instance.
Parameters: | optparseValues (optparse.Values) – Command-line options and their values. |
---|
Populates configuration with options specified on the command line.
Note
Options that are not defined in the Options class are skipped; it is assumed that they are commands for command-line UI.
Parameters: | configuration (_Configuration) – Configuration that should be populated. |
---|
_ConfigFileProcessor class.
Bases: builtins.object
Processes configuration files and populates IConfiguration instance.
Parameters: |
|
---|
Populates configuration with options.
Parameters: | configuration (_Configuration) – Configuration that should be populated. |
---|