plainbox.impl.providers.v1 – Implementation of V1 provider

Most of the implementation is available in

class plainbox.impl.providers.v1.Provider1(name, namespace, version, description, secure, gettext_domain, units_dir, jobs_dir, data_dir, bin_dir, locale_dir, base_dir, *, validate=False, validation_kwargs=None, check=True, context=None)[source]


A v1 provider implementation.

A provider is a container of jobs and test plans. It provides additional meta-data and knows about location of essential directories to both load structured data and provide runtime information for job execution.

Providers are normally loaded with Provider1PlugIn, due to the number of fields involved in basic initialization.


required value of CHECKBOX_SHARE environment variable.


This variable is only required by one script. It would be nice to remove this later on.


path of the directory with (perhaps) all of jobs_dir, data_dir, bin_dir, locale_dir. This may be None


absolute path of the bin directory


The programs in that directory may not work without setting PYTHONPATH and CHECKBOX_SHARE.


absolute path of the build/bin directory

This value may be None. It depends on location/base_dir being set.


absolute path of the build directory

This value may be None. It depends on location/base_dir being set.


absolute path of the build/mo directory

This value may be None. It depends on location/base_dir being set.


Exposed ProviderContentClassifier.classify()


Exposed ProviderContentEnumerator.content_collection()


absolute path of the data directory


description of this provider


List of all the executables


additional entry for PYTHONPATH, if needed.

This entry is required for CheckBox scripts to import the correct CheckBox python libraries.


The result may be None


Bridge to .content_collection.fake_plugins that’s shorter to type.

classmethod from_definition(definition, secure, *, validate=False, validation_kwargs=None, check=True, context=None)[source]

Initialize a provider from Provider1Definition object

  • definition – A Provider1Definition object to use as reference
  • secure – Value of the secure flag. This cannot be expressed by a definition object.
  • validate – Enable job validation. Incorrect job definitions will not be loaded and will abort the process of loading of the remainder of the jobs. This is ON by default to prevent broken job definitions from being used. This is a keyword-only argument.
  • validation_kwargs – Keyword arguments to pass to the JobDefinition.validate(). Note, this is a single argument. This is a keyword-only argument.

This method simplifies initialization of a Provider1 object where the caller already has a Provider1Definition object. Depending on the value of definition.location all of the directories are either None or initialized to a good (typical) value relative to location

The only value that you may want to adjust, for working with source providers, is locale_dir, by default it would be location/locale but i18n creates location/build/mo


Get a localized piece of data

Parameters:msgid – data to translate
Returns:translated data obtained from the provider if msgid is not False (empty string and None both are) and this provider has a gettext_domain defined for it, msgid itself otherwise.

the name of the gettext domain associated with this provider

This value may be empty, in such case provider data cannot be localized for the user environment.


Flag set if namespace was defined by a dedicated field.


A mapping from unit identifier to list of units with that identifier.


Typically the list will be one element long but invalid providers may break that guarantee. Code defensively if you can.


A sorted list of loaded job definition units.


absolute path of the jobs directory


absolute path of the directory with locale data

The value is applicable as argument bindtextdomain()


name of this provider


namespace component of the provider name

This property defines the namespace in which all provider jobs are defined in. Jobs within one namespace do not need to be fully qualified by prefixing their partial identifier with provider namespace (so all stays ‘as-is’). Jobs that need to interact with other provider namespaces need to use the fully qualified job identifier instead.

The identifier is defined as the part of the provider name, up to the colon. This effectively gives organizations flat namespace within one year-domain pair and allows to create private namespaces by using sub-domains.


A mapping from filename path to a list of units stored in that file.


For .pxu files this will enumerate all units stored there. For other things it will typically be just the FileUnit.


absolute path of the po/ directory

This value may be None. It depends on location/base_dir set.


list of problems encountered by the loading process


flag indicating that this provider was loaded from the secure portion of PROVIDERPATH and thus can be used with the plainbox-trusted-launcher-1.


absolute path of the src/ directory

This value may be None. It depends on location/base_dir set.


Get the translated version of description()


List of loaded units.

This list may contain units of various types. You should not assume all of them are JobDefinition instances. You may use filtering to obtain units of a given type.

>>> [unit for unit in provider.unit_list
...  if == 'job']

absolute path of the units directory


version of this provider

class plainbox.impl.providers.v1.InsecureProvider1PlugInCollection(**kwargs)[source]


A collection of v1 provider plugins.

This FsPlugInCollection subclass carries proper, built-in defaults, that make loading providers easier.

This particular class loads providers from both the system-wide managed locations and per-user location. In addition the list of locations searched can be changed by setting the PROVIDERPATH, which behaves just like PATH, but is used for looking up providers.


Time, in fractional seconds, that was required to discover all objects.

This time is separate from the load and wrap time of all each individual plug-in. Typically this is either a fixed cost or a predictable cost related to traversing the file system.

fake_plugins(plugins, problem_list=None)

Context manager for using fake list of plugins

  • plugins – list of PlugIn-alike objects
  • problem_list – list of problems (exceptions)

The provided list of plugins overrides any previously loaded plugins and prevent loading any other, real, plugins. After the context manager exits the previous state is restored.


Get a list of all the pairs of plugin name and plugin

Returns:a list of tuples (plugin.plugin_name, plugin)

Get a list of all the plug-in names

Returns:a list of plugin names

Get an list of plug-in objects


Get a list of all the plug-ins

Returns:a list of plugin objects

Get the specified plug-in (by name)

Parameters:name – name of the plugin to locate
Returns:PlugIn like object associated with the name
Raises:KeyError – if the specified name cannot be found
get_total_time() → float

Get the sum of load and wrap time of each plugin object

Returns:The total number of fractional seconds of wall-clock time spent by loading this collection. This value doesn’t include some small overhead of this class but is representative of the load times of pluggable code.

Load all plug-ins.

This method loads all plug-ins from the search directories (as defined by the path attribute). Missing directories are silently ignored.


List of problems encountered while loading plugins

wrap_and_add_plugin(plugin_name, plugin_obj, plugin_load_time)

Internal method of PlugInCollectionBase.

  • plugin_name – plugin name, some arbitrary string
  • plugin_obj – plugin object, some arbitrary object.
  • plugin_load_time – number of seconds it took to load this plugin

This method prepares a wrapper (PlugIn subclass instance) for the specified plugin name/object by attempting to instantiate the wrapper class. If a PlugInError exception is raised then it is added to the problem_list and the corresponding plugin is not added to the collection of plugins.


Computes the insecure value of PROVIDERPATH.

This value is not used by plainbox-trusted-launcher-1 executable since it would involve reading files outside of the control by the local administrator. This value is used for handing non-root jobs.

Returns:A list of three strings: * /usr/local/share/plainbox-providers-1 * /usr/share/plainbox-providers-1 * $XDG_DATA_HOME/plainbox-providers-1
comments powered by Disqus