plainbox.abc – abstract base classes

Those classes are actually implemented in the plainbox.impl package. This module is here so that the essential API concepts are in a single spot and are easier to understand (by not being mixed with additional source code).

Note

This module has API stability guarantees. We are not going to break or introduce backwards incompatible interfaces here without following our API deprecation policy. All existing features will be retained for at least three releases. All deprecated symbols will warn when they will cease to be available.

class plainbox.abc.IExecutionController[source]

Interface for job execution controller clases.

Execution controllers encapsulate knowledge on how to run command associated with a particular job. Some executors might run the command directly, others might delegate the task to a helper program or perform some special-cased customization to the execution environment.

execute_job(job, config, extcmd_popen)[source]

Execute the specified job using the specified subprocess-like object

Parameters:
  • job – The JobDefinition to execute
  • config – A PlainBoxConfig instance which can be used to load missing environment definitions that apply to all jobs. It is used to provide values for missing environment variables that are required by the job (as expressed by the environ key in the job definition file).
  • extcmd_popen – A subprocess.Popen like object
Returns:

The return code of the command, as returned by subprocess.call()

get_score(job)[source]

Compute how applicable this controller is for the specified job.

Returns:A numeric score, or None if the controller cannot run this job. The higher the value, the more applicable this controller is.
class plainbox.abc.IJobDefinition[source]

Job definition that contains a mixture of meta-data and executable information that can be consumed by the job runner to produce results.

command[source]

The shell command to execute to perform the job.

The return code, standard output and standard error streams are automatically recorded and processed, depending on the plugin type.

This value can be None

depends[source]

Comma-delimited dependency expression

This field can be used to express job dependencies. If a job depends on another job it can only start if the other job had ran and succeeded.

This is the original data as provided when constructed. Use get_direct_dependencies() to obtain the parsed equivalent.

This value can be None

description[source]

Human-readable description of the job.

This field is typically used to include execution and verification steps for manual and human-assisted tests.

This value can be None

id[source]

Unique job identifier

The identifier is unique within the provider a job belongs to

name[source]

Name of the job

plugin[source]

Name of the job interpreter.

Various interpreters are provided by the job runner.

requires[source]

List of expressions that need to be true for this job to be available

This value can be None

summary[source]

Short (one line) description of the job

class plainbox.abc.IJobQualifier[source]

An opaque qualifier for a job definition.

This is an abstraction for matching jobs definitions to names, patterns and other means of selecting jobs.

There are two ways to use a qualifier object. The naive, direct, old API can simply check if a qualifier designates a particular job (if it selects it and marks for subsequent execution). This API works fine for certain tasks but it was found that it is insufficient to implement so-called whitelist ordering, where the order of jobs in a whitelist is preserved when selecting that whitelist for execution. This spawned the second, lower-level API, that gives portable visibility into composite qualifiers (such as a whitelist) and distinct select, deselect vote so that full range of current expressiveness can be preserved.

Attr VOTE_EXCLUDE:
 (0) vote indicating that a job should not be included for selection. It overwrites any other votes.
Attr VOTE_INCLUDE:
 (1) vote indicating that a job should be included for selection. It is overridden by VOTE_EXCLUDE.
Attr VOTE_IGNORE:
 (2) vote indicating that a job should neither be included nor excluded for selection. This is a neutral value overridden by all other votes.
VOTE_EXCLUDE = 0
VOTE_IGNORE = 2
VOTE_INCLUDE = 1
designates(job)[source]

Check if this qualifier designates the specified plainbox.abc.IJobDefinition

Returns True:if the qualifier designates the specified job
Returns False:otherwise
get_primitive_qualifiers()[source]

Return a list of primitives that constitute this qualifier.

Returns:A list of IJobQualifier objects that each is the smallest, indivisible entity.

When each vote cast by those qualifiers is applied sequentially to a given job then the result is the same as the return value of the designates() method. The resulting list has more structure and this structure may matter to job ordering when a list of jobs is matched against a list of qualifiers. The resulting sets are identical but ordering of results is more accurately reflected by iterating over the fine structure of each qualifier.

get_vote(job)[source]

Get one of the VOTE_IGNORE, VOTE_INCLUDE, VOTE_EXCLUDE votes that this qualifier associated with the specified job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:one of the VOTE_xxx constants
is_primitive[source]

property indicating that a qualifier is not divisible by calling get_primitive_qualifiers().

If a qualifier is not primitive it can be replaced with a list of qualifiers it produces by the call to the aforementioned method.

class plainbox.abc.IJobResult[source]

Class for representing results from a single job

ALL_OUTCOME_LIST = [None, 'pass', 'fail', 'skip', 'not-supported', 'not-implemented', 'undecided']
OUTCOME_FAIL = 'fail'
OUTCOME_NONE = None
OUTCOME_NOT_IMPLEMENTED = 'not-implemented'
OUTCOME_NOT_SUPPORTED = 'not-supported'
OUTCOME_PASS = 'pass'
OUTCOME_SKIP = 'skip'
OUTCOME_UNDECIDED = 'undecided'
comments[source]

The comment that was added by the user, if any

get_io_log()[source]

Compute and return the sequence of IOLogRecord objects.

Returns:A sequence of tuples (delay, stream-name, data) where delay is the delay since the previous message seconds (typically a fractional number), stream name is either ‘stdout’ or ‘stderr’ and data is the bytes object that was obtained from that stream.
io_log[source]

A sequence of tuples (delay, stream-name, data) where delay is the delay since the previous message seconds (typically a fractional number), stream name is either ‘stdout’ or ‘stderr’ and data is the bytes object that was obtained from that stream.

outcome[source]

Outcome of the test.

The result of either automatic or manual verification. Depending on the plugin (test type). Available values are defined as class properties above.

return_code[source]

Command return code.

This is the return code of the process started to execute the command from the job definition. It can also encode the signal that the process was killed with, if any.

class plainbox.abc.IJobRunner[source]

Something that can run a job definition and produce results.

You can run many jobs with one runner, each time you’ll get additional result object. Typically you will need to connect the runner to a user interface but headless mode is also possible.

run_job(job)[source]

Run the specified job.

Calling this method may block for arbitrary amount of time. User interfaces should ensure that it runs in a separate thread.

The return value is a JobResult object that contains all the data that was captured during the execution of the job. Some jobs may not return a JobResult value.

class plainbox.abc.IProvider1[source]

Provider for the current type of tests

Also known as the ‘checkbox-like’ provider.

description[source]

description of this provider

get_all_executables()[source]

Discover and return all executables offered by this provider

get_builtin_jobs()[source]

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()[source]

Load all the built-in whitelists and return them

gettext_domain[source]

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.

load_all_jobs()[source]

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[source]

absolute path of the directory with locale data

The value is applicable as argument bindtextdomain()

name[source]

name of this provider

This name should be dbus-friendly. It should not be localizable.

namespace[source]

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.

version[source]

version of this provider

class plainbox.abc.IProviderBackend1[source]

Provider for the current type of tests.

This class provides the APIs required by the internal implementation that are not considered normal public APIs. The only consumer of the those methods and properties are internal to plainbox.

CHECKBOX_SHARE[source]

Return the 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[source]

directory where all the executables needed by this provider reside

data_dir[source]

absolute path of the data directory

extra_PYTHONPATH[source]

Return 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

jobs_dir[source]

Return an absolute path of the jobs directory

secure[source]

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

whitelists_dir[source]

Return an absolute path of the whitelist directory

class plainbox.abc.ISessionStateController[source]

Interface for session state controller classes.

Session state controller classes cooperate with SessionState and DependencySolver classes and implement knowledge unique to particular job semantics. Before execution the controller can influence job runnability (by setting inhibitors). After execution the controller can observe the result and influence session state

get_dependency_set(job)[source]

Get the set of direct dependencies of a particular job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:set of pairs (dep_type, job_name)

Returns a set of pairs (dep_type, job_name) that describe all dependencies of the specified job. The first element in the pair, dep_type, is either DEP_TYPE_DIRECT or DEP_TYPE_RESOURCE. The second element is the name of the job.

get_inhibitor_list(session_state, job)[source]

Get a list of readiness inhibitors that inhibit a particular job.

Parameters:
  • session_state – A SessionState instance that is used to interrogate the state of the session where it matters for a particular job. Currently this is used to access resources and job results.
  • job – A JobDefinition instance
Returns:

List of JobReadinessInhibitor

observe_result(session_state, job, result)[source]

Notice the specified test result and update readiness state.

Parameters:
  • session_state – A SessionState object
  • job – A JobDefinition object
  • result – A IJobResult object

This function updates the internal result collection with the data from the specified test result. Results can safely override older results. Results also change the ready map (jobs that can run) because of dependency relations.

class plainbox.abc.ITextSource[source]

An abstract source of text.

Concrete instances of this class are used by plainbox.impl.rfc822.Origin to keep track of where each entry of a RFC822-like document came from.

class plainbox.abc.IUserInterfaceIO[source]

Base class that allows job runner to interact with the user interface.

get_manual_verification_outcome()[source]

Get the outcome of the manual verification, as according to the user May raise NotImplementedError if the user interface cannot provide this answer.

Previous topic

plainbox – main package

Next topic

plainbox.impl – implementation package

This Page