plainbox.impl.commands.run – run sub-command

class plainbox.impl.commands.run.RunInvocation(provider_loader, config_loader, ns, color)[source]

Bases: plainbox.impl.commands.inv_checkbox.CheckBoxInvocationMixIn

Invocation of the ‘plainbox run’ command.

attr ns:
The argparse namespace obtained from RunCommand
attr _manager:
The SessionManager object
attr _runner:
The JobRunner object
attr _exporter:
A ISessionStateExporter of some kind
attr _transport:
A ISessionStateTransport of some kind (optional)
attr _backtrack_and_run_missing:
A flag indicating that we should run over all the jobs in the self.state.run_list again, set every time a job is added. Reset every time the loop-over-all-jobs is started.
ask_for_confirmation(message)[source]
ask_for_new_session()[source]
config
create_exporter()[source]

Create the ISessionStateExporter based on the command line options

This sets the attr:_exporter.

create_manager(storage)[source]

Create or resume a session that handles most of the stuff needed to run jobs.

This sets the attr:_manager which enables manager(), state() and storage() properties.

The created session state has the on_job_added signal connected to on_job_added().

Raises:SessionResumeError – If the session cannot be resumed for any reason.
create_runner()[source]

Create a job runner.

This sets the attr:_runner which enables runner() property.

Requires the manager to be created (we need the storage object)

create_transport()[source]

Create the ISessionStateTransport based on the command line options

This sets the attr:_transport.

do_initial_job_selection()[source]

Compute the initial list of desired jobs

do_normal_sequence()[source]

Proceed through normal set of steps that are required to runs jobs

expected_app_id
expected_session_title
export_and_send_results()[source]
exporter

The ISessionStateExporter of the current session

find_test_plan()[source]
get_completion_ratio()[source]
get_job_list(ns)

Load and return a list of JobDefinition instances

get_resume_candidates()[source]

Look at all of the suspended sessions and pick a list of candidates that could be used to resume the session now.

get_ui_for_job(job)[source]
get_whitelist_from_file(filename, stream=None)

Load a whitelist from a file, with special behavior.

Parameters:
  • filename – name of the file to load
  • stream – (optional) pre-opened stream pointing at the whitelist
Returns:

The loaded whitelist or None if loading fails for any reason

This function implements special loading behavior for whitelists that makes them inherit the implicit namespace of the provider they may be a part of. Before loading the whitelist directly from the file, all known providers are interrogated to see if any of them has a whitelist that was loaded from the same file (as indicated by os.path.realpath())

The stream argument can be provided if the caller already has an open file object, which is typically the case when working with argparse.

handle_last_job_after_resume()[source]
is_interactive

Flag indicating that this is an interactive invocation and we can interact with the user when we encounter OUTCOME_UNDECIDED

manager

SessionManager object of the current session

maybe_resume_session()[source]
maybe_warm_up_authentication()[source]

Ask the password before anything else in order to run jobs requiring privileges

metadata

SessionMetaData object of the current session

on_job_added(job)[source]

Handler connected to SessionState.on_job_added()

The goal of this handler is to re-select all desired jobs (based on original command line arguments and new list of known jobs) and set the backtrack_and_run_missing flag that is observed by _run_all_selected_jobs()

print_estimated_duration()[source]
provider_list
run()[source]
run_all_selected_jobs()[source]

Run all jobs according to the run list.

run_single_job(job)[source]
run_single_job_with_ui(job, ui)[source]
runner

JobRunner object of the current session

set_effective_categories()[source]
state

SessionState object of the current session

storage

SessionStorage object of the current session

store_application_metadata()[source]

Store application meta-data (app_id, app_blob) and session title

transport

The ISessionStateTransport of the current session (optional)

class plainbox.impl.commands.run.RunCommand(provider_loader, config_loader)[source]

Bases: plainbox.impl.commands.PlainBoxCommand, plainbox.impl.commands.cmd_checkbox.CheckBoxCommandMixIn

add_subcommand(subparsers)

Add a parser to the specified subparsers instance.

Returns:The new parser for the added subcommand

This command works by convention, depending on get_command_name(), :meth:`get_command_help(), get_command_description() and get_command_epilog().

autopager()

Enable automatic pager.

This invokes autopager() which wraps execution in a pager program so that long output is not a problem to read. Do not call this in interactive commands.

enhance_parser(parser)

Add common options for job selection to an existing parser

get_command_description()

Get a multi-line description string associated with this command, as seen on command line.

The description is printed after command usage but before argument and option definitions.

Returns:self.description, if defined
Returns:A substring of the class docstring between the first line (which goes to get_command_help()) and the string @EPILOG@, if present, or the end of the docstring, if any.
Returns:None, otherwise
get_command_epilog()

Get a multi-line description string associated with this command, as seen on command line.

The epilog is printed after the definitions of arguments and options

Returns:self.epilog, if defined
Returns:A substring of the class docstring between the string @EPILOG and the end of the docstring, if defined
Returns:None, otherwise
get_command_help()

Get a single-line help string associated with this command, as seen on command line.

Returns:self.help, if defined
Returns:The first line of the docstring of this class, if any
Returns:None, otherwise
get_command_name()

Get the name of the command, as seen on command line.

Returns:self.name, if defined
Returns:lower-cased class name, with the string “command” stripped out
get_gettext_domain()

Get the gettext translation domain associated with this command.

The domain will be used to translate the description, epilog and help string, as obtained by their respective methods.

Returns:self.gettext_domain, if defined
Returns:None, otherwise. Note that it will cause the string to be translated with the globally configured domain.
get_localized_docstring()

Get a cleaned-up, localized copy of docstring of this class.

gettext_domain = 'plainbox'
invoked(ns)[source]
register_arguments(parser)

Implement to customize which arguments need to be added to a parser.

This method differs from register_parser() in that it allows commands which implement it to be invoked directly from a tool class (without being a subcommand that needs to be selected). If implemented it should be used from within register_parser() to ensure identical behavior in both cases (subcommand and tool-level command)

register_parser(subparsers)[source]
comments powered by Disqus