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

Most of the implementation is available in plainbox.impl.secure.providers.v1

class plainbox.impl.providers.v1.DummyProvider1(job_list=None, whitelist_list=None, **extras)[source]

Dummy provider useful for creating isolated test cases

CHECKBOX_SHARE[source]
bin_dir[source]
data_dir[source]
description[source]
extra_PYTHONPATH[source]
get_all_executables()[source]
get_builtin_jobs()[source]
get_builtin_whitelists()[source]
gettext_domain[source]
jobs_dir[source]
load_all_jobs()[source]
locale_dir[source]
name[source]
namespace[source]
secure()[source]
version[source]
whitelists_dir[source]
class plainbox.impl.providers.v1.Provider1(name, version, description, secure, gettext_domain, jobs_dir, whitelists_dir, data_dir, bin_dir, locale_dir)

A v1 provider implementation.

A provider is a container of jobs and whitelists. 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.

CHECKBOX_SHARE

required value of CHECKBOX_SHARE environment variable.

Note

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

bin_dir

absolute path of the bin directory

Note

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

data_dir

absolute path of the data directory

description

description of this provider

extra_PYTHONPATH

additional entry for PYTHONPATH, if needed.

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

Note

The result may be None

classmethod from_definition(definition, secure)

Initialize a provider from Provider1Definition object

Parameters:
  • definition – A Provider1Definition object to use as reference
  • secure – Value of the secure flag. This cannot be expressed by a definition object.

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 manage.py i18n creates location/build/mo

get_all_executables()

Discover and return all executables offered by this provider

Returns:list of executable names (without the full path)
Raises IOError, OSError:
 if there were any problems accessing files or directories. Note that OSError is silently ignored when the bin_dir directory is missing.
get_builtin_jobs()

Load and parse all of the job definitions of this provider.

Returns:

A sorted list of JobDefinition objects

Raises:
  • RFC822SyntaxError – if any of the loaded files was not valid RFC822
  • IOError, OSError – if there were any problems accessing files or directories. Note that OSError is silently ignored when the jobs_dir directory is missing.
..note::
This method should not be used anymore. Consider transitioning your code to load_all_jobs() which is more reliable.
get_builtin_whitelists()

Load all the whitelists from whitelists_dir and return them

This method looks at the whitelist directory and loads all files ending with .whitelist as a WhiteList object.

Returns:A list of WhiteList objects sorted by plainbox.impl.secure.qualifiers.WhiteList.name.
Raises IOError, OSError:
 if there were any problems accessing files or directories. Note that OSError is silently ignored when the whitelists_dir directory is missing.
get_translated_data(msgid)

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.
gettext_domain

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.

jobs_dir

absolute path of the jobs directory

load_all_jobs()

Load and parse all of the job definitions of this provider.

Unlike get_builtin_jobs() this method does not stop after the first problem encountered and instead collects all of the problems into a list which is returned alongside the job list.

Returns:Pair (job_list, problem_list) where each job_list is a sorted list of JobDefinition objects and each item from problem_list is an exception.
locale_dir

absolute path of the directory with locale data

The value is applicable as argument bindtextdomain()

name

name of this provider

namespace

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.

secure

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

tr_description()

Get the translated version of description()

version

version of this provider

whitelists_dir

absolute path of the whitelist directory

class plainbox.impl.providers.v1.InsecureProvider1PlugInCollection[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.

plainbox.impl.providers.v1.get_insecure_PROVIDERPATH_list()[source]

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

Previous topic

plainbox.impl.providers.special – various special providers

Next topic

plainbox.impl.resource – job resources

This Page