plainbox.impl.applogic – application logic

Warning

THIS MODULE DOES NOT HAVE STABLE PUBLIC API

class plainbox.impl.applogic.PlainBoxConfig[source]

Bases: plainbox.impl.secure.config.Config

Configuration for PlainBox itself

class Meta

Bases: plainbox.impl.applogic.Meta, plainbox.impl.secure.config.ConfigMetaData

filename_list = ['/etc/xdg/plainbox.conf', '/home/docs/.config/plainbox.conf']
parametric_section_list = []
section_list = [<plainbox.impl.secure.config.Section object>]
variable_list = [<Variable name:'extcmd'>]
PlainBoxConfig.environment

Environment variables for scripts and jobs

PlainBoxConfig.extcmd

Which implementation of extcmd to use

PlainBoxConfig.filename_list

list of pathnames to files that were loaded by the last call to read()

PlainBoxConfig.get()

Get an instance of this Config class with all the configuration loaded from default locations. The locations are determined by Meta.filename_list attribute.

Returns:fresh Config instance
PlainBoxConfig.get_parser_obj()

Get a ConfigParser-like object with the same data.

Returns:A PlainBoxConfigParser object with all of the data copied from this Config object.

Since PlainBoxConfigParser is a subclass of configparser.ConfigParser it has a number of useful utility methods. By using this function one can obtain a ConfigParser-like object and work with it directly.

PlainBoxConfig.problem_list

list of ValidationError that were detected by the last call to read()

PlainBoxConfig.read(filename_list)

Load and merge settings from many files.

This method tries to open each file from the list of filenames, parse it as an INI file using PlainBoxConfigParser (a simple ConfigParser subclass that respects the case of key names). The list of files actually accessed is saved as available as Config.filename_list.

If any problem is detected during parsing (e.g. syntax errors) those are captured and added to the Config.problem_list.

After all files are loaded each Variable and Section defined in the Config class is assigned with the data from the merged configuration data.

Any variables that cannot be assigned and raise ValidationError are ignored but the list of problems is saved.

All unused configuration (extra variables that are not defined as either Variable or Section class) is silently ignored.

Note

This method resets _problem_list and _filename_list.

PlainBoxConfig.read_string(string)

Load settings from a string.

Parameters:string – The full text of INI-like configuration to parse and apply

This method parses the string as an INI file using PlainBoxConfigParser (a simple ConfigParser subclass that respects the case of key names).

If any problem is detected during parsing (e.g. syntax errors) those are captured and added to the Config.problem_list.

After parsing the string each Variable and Section defined in the Config class is assigned with the data from the configuration data.

Any variables that cannot be assigned and raise ValidationError are ignored but the list of problems is saved.

All unused configuration (extra variables that are not defined as either Variable or Section class) is silently ignored.

Note

This method resets _problem_list and _filename_list.

PlainBoxConfig.validate_whole()

Validate the whole configuration object.

This method may be overridden to provide whole-configuration validation. It is especially useful in cases when a pair or more of variables need to be validated together to be meaningful.

The default implementation does nothing. Other implementations may raise ValidationError.

PlainBoxConfig.write(stream)

Write configuration data to a stream.

Parameters:stream – a file-like object that can be written to.

This method recreates the content of all the configuration variables in a manner that can be subsequently read back.

plainbox.impl.applogic.get_all_exporter_names()[source]

Get the identifiers (names) of all the supported session state exporters.

Returns:A list of session exporter names (identifiers) available from all the providers.

This function creates a temporary session associated with the local device and adds all of the available providers to it. Finally, it returns the list of exporter names. The session is transparently destroyed.

plainbox.impl.applogic.get_matching_job_list(job_list, qualifier)[source]

Get a list of jobs that are designated by the specified qualifier.

This is intended to be used with CompositeQualifier but works with any IJobQualifier subclass.

plainbox.impl.applogic.get_whitelist_by_name(provider_list, desired_whitelist)[source]

Get the first whitelist matching desired_whitelist from the loaded providers

plainbox.impl.applogic.run_job_if_possible(session, runner, config, job, update=True, ui=None)[source]

Coupling point for session, runner, config and job

Returns:(job_state, job_result)
comments powered by Disqus