Dovetail API implementation.
Module: loader.py Module: model.py
build file +--------------+
+-------------+ +-------------+ +-------------+ | Dependencies |
| |------>| |<------*| | +--------------+
| PackageNode | | BuildModule | | Task |
| |*-+ | |*-+ | | +--------------+
+-------------+ | +-------------+ | +-------------+ | TaskWrapper |
\___/ \___/ ^ +--------------+
Package Loaded |
Structure | Objects in model.py are related
| but look each other up dynamically
*
+--------------+
| |
+-------------+ <<creates>> | Execution |
| |~~~~~~~~~~~~~~~~~~>| |*-+
| | +--------------+ |
| Processor | ^ \___/
| | |
| | <<creates>> +--------------+
| |~~~~~~~~~~~~~~~~~~>| |
+-------------+ | Result |
| |
+--------------+
Module: engine.py
Links:
PackageNode: Model of package/directory structure of the build files
BuildModule: Models build files
- Task: Model of a Task
- Dependencies: Stores dependencies between Tasks
- TaskWrapper: Directives (such as @do_if or @adjust_env)
The major flow of events when running within the same Python VM:
. main.py . loader.py . engine.py .
. . . .
. +-------------+ . . .
. | main() | . . .
. +-------------+ . . .
. | . . .
. v . . .
. +-------------+ . +--------+ This instantiates the .
. | inner() |----->| load() | PackageNode, BuildModule .
. +-------------+ . +--------+ and Task objects .
. | . . .
. v . . .
. +-------------+ . . .
. | execute_in_ | . . +---------+ +----------------------+ .
. | vm() |-------------------->| build() |--->| Processor._execute() | .
. +-------------+ . . +---------+ +----------------------+ .
. . . .
Links:
main(): Entry point from the command line
- load(): Loads build files creating:
- PackageNode: Models the packages
- BuildModule: Models build files
- Task: Task instances (and other associated structures)
build(): Runs the build
Note
execute_in_vm() calls stamp_environment() to set a number of environment variables before the call to build()
The Processor ‘runs’ a build using the following algorithm to execute a single Task, recording activity in Execution instances on a stack. The Execution states are defined in the Enumeration dovetail.engine.STATE:
Method Processor._execute(self, task):
Begin: Push a new Execution frame onto the stack
Check for errors:
- 2.1. Check if we have already run this task. If update the frame to STATE.REPEATED
and go to #10
- 2.2. Check if there is a circular invocation which has lead to
an infinite recursion. If so, fail the build and go to #10
CWD: Change working directory unless specifically disabled with @cwd(None)
Directives: Execute the TaskWrapper.before() method of all directives
Dependencies: If Execution.state is not STATE.SKIPPED or STATE.FAILED:
5.1. Loop over Task.dependencies()
- 5.1.1. Recursive call to Processor._execute() to execute the Task.
If the execution was not successful (Execution.is_ok() is False), fail this Task with STATE.ABORT and go to #8
CWD: Check the working directory to ensure that anything the dependents did is reverted here before the main body of the Task runs
Body: Execute the Task body by execute the function returned by Task.get_function()
Directives: Execute the TaskWrapper.after() method of all directives in reverse order
If nothing went wrong, mark this Execution with STATE.SUCCEEDED
CWD: Reset the working directory
End: Pop the Execution stack frame
This method is heavily error-trapped and guarded - in the event that any failures occur in the directives (in the TaskWrapper.before() and TaskWrapper.after() methods) or the task dependencies or the task’s function, the method will catch the error and fail gracefully and safely.
Note
Exceptions raised during this process can trigger two different outcomes:
Handles the command-line parameter configuration and the configuration files
Values that are considered ‘True’ in the configuration file
Bases: object
A class which encapsulates an option in the Dovetail section of the configuration file, and the code to validate the entry and map it to the internal data model.
Parameters: |
|
---|
Values that are considered ‘True’ in the configuration file
Takes a config file (in parser) and applies the Dovetail section to the argparser (or dictionary) in args.
Parameters: |
|
---|---|
Raises : |
Reads the Environment section of a ConfigParser, writing all entries to os.environ.
Parameters: | parser (class:ConfigParser.ConfigParser) – The ConfigParser |
---|
For each item in [Environment], an environment variable will be set in os.environ with the item’s value.
Returns the string as a boolean.
Parameters: | boolean_as_string (string) – A string, eg from the config file |
---|---|
Returns: | The boolean representation of boolean_as_string |
Return type: | boolean |
coerce_to_boolean() is not case sensitive. It looks up appropriate values for True from TRUE.
It is assumed that boolean_as_string is valid (i.e. has already been passed to is_a_boolean() without ValueError
Creates the command line parser.
Returns: | An ArgumentParser instance |
---|---|
Return type: | argparse.ArgumentParser |
Looks at the various ini file locations and probes them; if it finds a config file, it will use load_config_file() to load the file, and return the then return the ConfigParser.SafeConfigParser for it.
Returns: | A ConfigParser loaded from the best configuration file found or None |
---|---|
Return type: | ConfigParser.SafeConfigParser |
See load_config() for more details
Returns without error if the string can be mapped to a boolean.
Parameters: | boolean_as_string (string) – The string from a config file |
---|---|
Returns: | The value as a boolean |
Return type: | boolean |
Raises : | ValueError if boolean_as_string is not in BOOLEAN |
Loads the configuration for Dovetail from configuration files and the command-line arguments; command line overrides configuration files.
Parameters: | command_line_args (list of string) – The command line arguments |
---|---|
Returns: | An ArgumentParser with modifications from the config file |
Return type: | argparse.ArgumentParser |
The configuration file is found with find_best_config(). It is in two sections:
Loads the config file named in config_file into a SafeConfigParser, validating the file argument
Parameters: | config_file (string) – A path to a configuration file to be read |
---|---|
Returns: | A configuration parser with the file loaded in it |
Return type: | ConfigParser.SafeConfigParser |
Returns the correct enumeration value for the Log Level.
Parameters: | level (string) – A Log dovetail.util.logging.LEVEL value |
---|---|
Returns: | The log level enumeration value |
Return type: | int |
Raises : | ValueError if level is not a valid log level |
Utility function to print the help of the Dovetail argparser.
Parameters: | out_file (File Object) – Default None (std_out). An optional file stream to write the help to |
---|
Utility function to print the usage instructions of the Dovetail argparser.
Parameters: | out_file (File Object) – Default None (std_out). An optional file stream to write the help to |
---|
Returns a list of space-separated items in the string; if the string is empty, an empty list is returned
Parameters: | words (string) – A space-separated series of items |
---|---|
Returns: | Splits the string on spaces, returning a list of items. If words if None or empty, the empty list is returned |
Return type: | list |
Version and product information constants
Description of Dovetail for setup.py
Development status for setup.py
The version of Dovetail, for setup.py
Returns the contants of the file as a string
The processing engine and state objects.
Bases: object
A stack frame recording the internal and external aspects of processing a Task and its dependents.
Parameters: | task (Task) – The task whose execution is recorded |
---|
The Execution stack is returned to by build() function wrapped in a Result.
Attributes:
Attribute | Type | Description |
---|---|---|
task | Task | A reference to the Task that ran. |
state | Enum from STATE | Record of the state of the processing. See state table see STATE |
start, finish | datetime.datetime | Start and end time of processing. If the processing has not finished, finish is None |
parent | Execution | The Execution instance that directly or indirectly invoked this task |
dependents | list of Execution | List of Execution instances of direct or indirect task invocations |
skip_reasons | list of string | Accumulated messages from @skip_if, @do_if or any other cause of this task being skipped |
result | any | The return value of the Task (if successful) |
exception | Exception | If the task failed, the Exception that was thrown from the Task |
exc_type, exc_value, exc_traceback | Details from the exception retrieved by sys.exc_info(). |
Adds another Execution instance as a child of this.
Parameters: | execution (Execution) – A child task of this |
---|
Set the state of the class:Execution to indicate that a Task has called build() and that task has completed
Set the state of the Execution to indicate that a Task has called build() to run another Task.
This state continues only until the called Task returns
Returns the number of Execution instances in the tree.
If this has no children, it will return 1
Returns the depth of this call in the call stack.
Returns: | Depth of this Execution in the call stack |
---|---|
Return type: | int |
Returns how long the task took, including dependencies.
Returns: | Duration of execution |
---|---|
Return type: | float |
Returns the duration that the dependencies of this Execution took to execute
Returns: | Duration of dependency execution |
---|---|
Return type: | float |
Returns the time inherent in processing the Task, i.e. less its dependencies
Returns: | Duration of execution of the Task |
---|---|
Return type: | float |
Returns a list of all executions from this point down the graph ordered by their elapsed internal duration (eg exclude) with the longest elapsed executions first
Set the state to indicate the Task failed with an exception.
Parameters: | exception (Exception) – The exception thrown by the task |
---|
Searches the Execution graph for the Execution object which failed the build, either returning the Execution object or None
Returns: | The Exception which maps to the Task which failed the build. Returns None if no exception |
---|---|
Return type: | Execution or None |
Returns a list containing this and all dependent Executions
Returns a formatted exception message, exactly as Python does, for the exc_type, exc_value and exc_traceback attributes.
Returns: | Formatted exception |
---|---|
Return type: | string |
Returns a list of Message objects that were logged.
Returns: | Messages recorded during the execution of the task |
---|---|
Return type: | list of Message |
Returns True if this node failed and captured a stack trace
Runs sys.exc_info() to stamp this object with the stack trace of the current exception
Set the state of the Execution to indicate processing of the internal task itself (dependencies complete)
Is the Task complete?
Returns: | Returns True if the Task has completed execution, successfully or not |
---|---|
Type : | boolean |
Returns True if the Task has completed execution without error.
Returns: | Returns True if Execution.state is SKIPPED, SUCCEEDED or REPEATED |
---|---|
Type : | boolean |
Log a message to be recorded on the Execution object.
Parameters: | message (string) – A message |
---|
This may later be retrieved programmatically or reported
Returns true if the Execution received any error messages from stderr.
Returns: | Did this task generate output on stderr? |
---|---|
Return type: | boolean |
Retrieves a value from the Execution frame store
Works in conjunction with store().
Sets the result of the Task.
Note
This has to be set before the Task is said to be complete because the TaskWrapper.after() directives may fail the overall result
Set the state to indicate the Task was skipped.
Parameters: | reason (string) – The reason for skipping the Task |
---|
Stores the key-value pair in a dictionary in the Execution frame for later retrieval allowing multiple participants to share data.
store() works in conjunction with retrieve() to create a:
- Shared whiteboard - use simple keys such as strings, or
- Private rendezvous for mementos - use a private key such as a function reference
Set the state to indicate the execution was successful, capturing the result
Update the state to record that a system exception has occurred, and to fail the ongoing build.
Parameters: | exception (Exception) – A system exception thrown by Dovetail, a directive or predicate |
---|
Reference to the Processor singleton
Bases: object
The processor that runs tasks and their decorators and maintains a call stack of Execution instances.
To run (or build) a Task, use the build() function.
Bases: object
The results of executing a build.
Result is constructed by Processor after the build has completed, successfully or otherwise.
Parameters: | execution (Execution) – The top-level stack frame |
---|
Attributes:
Attribute | Type | Description |
---|---|---|
task | Task | A reference to the Task that ran. If the build was launched with multiple tasks this will be the NullTask |
success | boolean | A boolean indicating if this run was successful or not |
result | any | The return value of the Task (if successful) |
execution | Execution | A reference to the Execution instance containing a complete history of the run |
exception | Exception | If the run failed, the Exception that was thrown from the failing Task |
exc_type, exc_value, exc_traceback | Details from the exception retrieved by sys.exc_info(). |
Returns a report banner including most information required to identify this build
Returns a formatted exception message, exactly as Python does, for the exc_type, exc_value and exc_traceback attributes.
Convenience method - delegates to the topmost execution object.
If no exception this method returns the empty string
Report the slowest tasks in the build (comprising >80% of build time, and being faster than 1ms)
Produce a report of the structure of the Tasks and their results
Returns a list of the the top-level Tasks that were executed.
If the top-level task is the logical grouping task, this will return the logical grouping’s dependents
An enumeration capturing the state of execution.
Execution is modelled as a state machine with the following states:
- STATE.STARTED: The Execution instance has been freshly created
- STATE.DEPENDENTS: The Processor is executing the Task dependencies from Dependencies
- STATE.RUNNING: The Processor is executing the main body of the Task
- STATE.CALLING: A Task is programmatically calling another Task
- STATE.SKIPPED: Directives caused the Task to be skipped (not executed) but treated as successful
- STATE.SUCCEEDED: The Task completed normally
- STATE.FAILED: The Task itself failed (raising an exception)
- STATE.ABORTED: A dependent Task of this Task failed. The Processor makes no attempt to run the main body of the Task
- STATE.REPEATED: A Task had already been executed (perhaps as a dependency or directly invoked); it is not executed again
And models state transitions as:
.---------------------------------------------------.
/ .-----------------------------------> SKIPPED >--.|
/ / .----------------------. ||
/ / / | .------> SUCCEEDED ||
/ / / v / ||
STARTED ---> DEPENDENTS ---> RUNNING >-----> FAILED <---+'
| | | ^ ^
v v v | |
REPEATED ABORTED CALLING >---------'
Note
alias of Enum
Execute one task, optionally handling exceptions.
Parameters: |
|
---|---|
Returns: | |
Return type: | |
Raises : | If handle_exceptions is False, build() will raise the Exception raised by the Task that failed |
handle_exception behaviour:
False (default): If a Task throws an exception, or fails, the exception is propagated to the caller.
True: The any exception thrown is handled by the function and the exception is wrapped in the Result object. The result of the call can be checked with:
if result.success is False: # do error handling print result.exception
Warning
This function is for use within a task. Use run() to start a build as discussed in Running Dovetail
A PEP 302 Python import hook for loading build scripts with classes that model the loaded packages and modules.
This behaves differently from the built-in loader by loading Python files from subdirectories without the presence of the __init__.py.
The loader is created on a base directory and searches by converting them into a directory under the base. For example:
>>> # assuming a file "build.py" in /path/to/build/root
>>> load("/path/to/build/root/build.py")
Building in /path/to/build/root
>>> # assuming build.py in directory ./path/to/directory under /path/to/build/root
>>> load("path/to/directory/build.py")
>>> # assuming @task declared on a function test() in build.py above
>>> build("path.to.directory.build:test")
Bases: object
A PEP 302 Python loader to import build scripts and their dependencies.
Bases: object
A class implementing a PEP 302 load_module import hook for a directory.
Directories loaded into Dovetail with this loader contain ONLY references to the packages loaded from their directory. Otherwise they are empty and do not have the __init__.py semantics
Bases: object
A class implementing a PEP 302 load_module import hook for a file.
Files can be loaded from any subdirectory of base_directory. Functions and classes can be referenced like:
>>> import path.to.file
>>> path.to.file.function()
Or:
>>> from path.to.file import function
>>> function()
A PEP 302 import hook for BuildLoader
Returns true if a BuildLoader import hook as been installed
Creates and registers a BuildLoader instance with the Python loader.
Parameters: | base_directory (string) – The base directory for the build. Files outside this directory will not load |
---|---|
Returns: | The build loaded singleton |
Return type: | BuildLoader |
Warning
This must be called precisely once
Bases: object
An object that represents a single build file loaded in Dovetail.
All build files must be loaded by Dovetail using load(). Dovetail will not run Task in files loaded by, for example, the import statement. Indeed, if the Task functions are called directly, Dovetail will decline to run them.
BuildModule works with PackageNode. The latter represent each loaded package. Leaves on the package tree may be modules. These modules are modelled by a BuildModule.
Parameters: |
|
---|
Attribute | Type | Description |
---|---|---|
name | string | The unqualified name of the module containing the build file (the name of the file, less the .py extension) |
file_name | string | The file name of the loaded build file |
module | module | Reference to the Python module containing the build. Note that module.__file__ is equal to file_name |
parent | BuildModule | The BuildModule that loaded (directly or indirectly) this BuildModule |
tasks | dict of {string: Task} | A dict of task-name -> Task instance. The key is the short name for the Task |
loaded | list of BuildModule | A list of BuildModule instances which this build file directly (or indirectly) loaded. The order of the list is the order the dependencies where loaded. |
Type : | string |
---|
The base directory for the build
Get the build module that’s currently running.
Returns: | the highest BuildModule found in the stack. |
---|---|
Return type: | BuildModule |
Finds the BuildModule for the Python module argument
Parameters: | module (Python module instance or the name of the module) – The module to search for |
---|---|
Returns: | The BuildModule that wraps the module |
Return type: | BuildModule |
Raises : | NoSuchModule if the module was not loaded by Dovetail |
Searches for task name in this BuildModule and it’s children.
Parameters: | name (string) – The name of a Task. Accepts both non-qualified and fully-qualified Task names |
---|---|
Returns: | The task |
Return type: | Task |
Raises : | NoSuchTask |
Interrogates children directly loaded by this module and returns a list of Tasks with the name given in the argument.
This method allows a Task, say ‘clean’, in a parent build file to automatically call ‘clean’ in each of its descendants.
Parameters: | name (string) – The name of a Task. The name must be the function name, not the fully qualified name. |
---|---|
Returns: | All the tasks with that name under this BuildModule |
Return type: | list of Task (may be an empty list) |
Returns the file name, relative to the build root, of this module
Register a task with the BuildModule database.
Parameters: | task (Task) – The task that has just been loaded |
---|---|
Raises : | NoSuchModule if the task was declared in a file that was not loaded via load() |
Type : | BuildModule |
---|
A reference to the build’s root build file
A data structure for describing package structure and which packages are associated with BuildModule instances.
PackageNode is a model of the tree structure of the build files loaded by Dovetail and their relative directory locations. It closely resembles the package structure in Python and uses the same dotted notation as Python.
Parameters: | full_name (string) – The full name of the package being loaded |
---|
Attribute | Type | Description |
---|---|---|
name | string | The non-qualified name of this file |
full_name | string | The full Python-style package name for this package, eg for top/subdir/build.py, full name is top.subdir.build |
parent | PackageNode | The parent of this instance |
children | set of PackageNode | The child packages of this package |
build_module | BuildModule | For a PackageNode representing a file (rather than directory) this points to the corresponding BuildModule, otherwise None |
Adds a PackageNode as a child of this one.
Parameters: | node (PackageNode) – The PackageNode to be added to children |
---|
Find a child of the given name.
Parameters: | name (string) – The name to search for in children |
---|---|
Returns: | The child PackageNode if present, else None |
Return type: | PackageNode |
Recursively removes this node and children from the graph
Finds a PackageNode instance for the given package.
Parameters: | module (string or BuildModule) – Name of the package to find |
---|---|
Returns: | The associated PackageNode |
Return type: | PackageNode |
Raises : | KeyError if there is no such PackageNode |
The PackageNode graph does not include packages that are loaded but are independent of the build files loaded by load() (and have corresponding BuildModule instances)
Returns the root PackageNode of the package graph
Invalidates the package graph forcing re-discovery next time get_root is called.
This is called whenever the PEP 302 hook ‘BuildLoader’ detects that import has been called
Returns True if the node is a leaf (eg no PackageNodes have been loaded by this node
Prints a graph of the PackageNode instances to the console
Returns whether Dovetail has loaded itself and is ready to load directives
Load a build file which may be specified as a relative or absolute path (relative paths are relative to the file of the calling script).
Load will only load files in or under the build root (which is set as the directory containing the first build file loaded by Dovetail).
Paths may be specified with either forward or backward slash.
>>> # Load another.py in the same directory as the calling script
>>> load("another.py")
>>> # Load another.py in directory 'dir' under the directory of the calling
>>> # script:
>>> load("dir/another.py")
>>> # or
>>> load("dir\another.py")
>>> # Load a specific file:
>>> load("/path/to/build/root/build.py")
The very first call to load() should either supply an absolute path which will set the build’s base directory. Failing this, the current working directory is used to establish the build root.
Command-line entry-point.
Execute the build in the current Python VM.
Parameters: |
|
---|---|
Returns: | 0 if successful, 1 if the build failed |
Return type: | int |
Raises : | Terminate if Dovetail itself crashes. Build steps will not raise this exception. |
Note
execute_in_vm() calls stamp_environment() to set a number of environment variables. These can be used by the build script to better understand the environment
Dovetail main entry point.
Exceptions thrown due to errors in command line arguments or system errors are caught and an appropriate message and/or banner is displayed to the user rather than cryptic stack traces, and Dovetail exits the Python interpreter.
Print all the reports specified in the second argument to the console on the Results passed as the first argument.
Report the tasks in the specified module in a simple one-level tree
Used to run tasks from in a build script when the script has been loaded directly by Python.
When a script is run in the following way:
$ python build.py task1 task2
It can invoke Dovetail functionality using this fragment:
from dovetail import *
import sys
...
if __name__ == "__main__":
run(sys.argv[1:])
Parameters: | tasks (list of string) – One or more tasks to run. Can be non-qualified task names if they are present in build_file, or fully-qualified task names for those in other files |
---|---|
Returns: | 0 if successful, 1 if the build failed |
Return type: | int |
Raises : | Terminate if Dovetail itself crashes. Build steps will not raise this exception. |
Note
Warning
Read the warnings in Running Dovetail
Validate arguments and attempt to print help on the tasks
Processes the list of Task targets into a list of normalized task names.
The method also validates the list of tasks in the module name provided.
The object model for Dovetail.
Bases: object
A simple dictionary-based store for recording dependencies of one Task on another.
This is an internal object used by the depends() directive and the Task class.
This class does not handle automatic dependencies (see Automatic dependencies).
Bases: dovetail.model.Task
A minor specialization of Task that registers with BuildModule so that its dependencies can be resolved.
Bases: dovetail.model.Task
A logical root of the Task dependency hierarchy when the user specifies multiple Tasks from the command line. This allows the Task graph to be logically single-rooted.
This object is stored in dovetail.model.NULL_TASK
Returns a list of Task instances on which this Task depends.
This includes tasks of the same name in child modules
Called to anchor the Null Task as logically associated with the build file specified on the command line.
This is needed so that children of the NullTask have a build root.
Bases: object
An object representing a Task in a build system.
Tasks are functions, taking no arguments, identified with the ‘@task’ directive. A task’s short name is the name of the function. A hello-world for Dovetail is:
from dovetail import task
@task
def hello_world():
pass
Parameters: | func (function()) – A reference to the task’s function |
---|
Tasks have the following members:
Attribute | Type | Description |
---|---|---|
module | module | The module in which the Task function is declared |
func_name | string | The name of the function (f.__name__) |
name | string | The fully qualified name of the Task |
source | string | The absolute path of the file in which the Task is declared |
dir | string | The directory in which source is situated |
At instantiation time, the task instance captures the name and module of the task’s function - it does not capture a reference to the function. This approach means the function can be decorated or otherwise modified after the @task decorator is processed and the Task instance will ‘see’ the additional decoration.
At the time of resolution in get_function(), the module’s namespace is interrogated for the function name.
A task (in the build sense) is modelled by a combination of classes:
Class | Description |
---|---|
Task | The class models the core aspects of a task and provides a in-memory datastore for all tasks. |
TaskWrapper | A algorithmic class that captures the wrapping behaviour of directives such as @Env and @do_if |
Dependencies | A data store capturing all the dependencies of every task loaded. Dependencies are not resolved until runtime to allow forward references in build files. The class provides an API to look up any task’s dependencies. |
TaskWorkingDirectories | A data store capturing the path specified in the @cwd directive. This is needed because the Task has not been created when the @cwd directive is processed. |
Implementation note: There is a special Null Task always present that is used to to logically root a graph of Tasks. This can be retrieved from dovetail.model.NULL_TASK.
A utility to create a Task name for a function.
Parameters: | func (function()) – The function |
---|---|
Returns: | Task name. The name is typically of the form “module:function”, but module name is dropped for the __main__ module |
Return type: | string |
Builds out a tree of Task dependencies for reporting.
Returns: | A directed graph of Task dependencies |
---|---|
Return type: | Node |
Node Class | ||
---|---|---|
Attribute | Type | Description |
task | function() or string | The Task |
children | list of function() or string | Dependencies of the task |
Returns a list of Task instances on which this Task depends.
Returned dependencies include both the explicit dependencies created by @depends and stored in Dependencies, and also automatic dependencies between tasks of the same name in different files (see Automatic dependencies).
This is an abstract method implemented in:
Return the Task instance for the task of this name or function.
The Task can be looked up by passing a function reference - this is the easiest approach. You can also look up by Task name, which is relative to the package you are in. Tasks in the same file have the same name as the function. Otherwise Tasks declared at or below this use a relative package naming scheme, eg “package:function_name” - see Task names
The module argument can be specified to determine the starting point of the relative name search. If None, the call stack is examined to start the search from the file highest on the stack loaded by dovetail.load().
Parameters: | |
---|---|
Returns: | The requested Task |
Return type: | |
Raises : |
Note
Gets the Task instance’s documentation string.
Returns: | The reformatted docstring from the Task’s implementation |
---|---|
Return type: | string |
Returns the function implementing this task.
This is looked up by name within the module namespace at the point of request.
Returns the directory in which the Task wants to be run.
Returns: | The Task‘s working directory |
---|---|
Return type: | string |
This defaults to the Task.dir, but can be set directly. The working directory has several levels of default, in this order:
- Value set using TaskWorkingDirectories or the cwd() directive
- Task.dir
If TaskWorkingDirectories or cwd() explicitly sets the working directory to None (eg @cwd(None)), then the the Dovetail engine switches of working directory functionality for this task, and the task will execute in the working directory of the calling task.
Returns the TaskWrapper instances associated with this Task.
Returns: | The directives |
---|---|
Return type: | list of TaskWrapper |
Prints a report of this Task and all its children, recursively; each Task’s docstring is printed
Writes one line in the Task report report - the Task name and docstring
Bases: object
A simple dictionary for storing @cwd directive working directory values and their retrieval.
This class is necessary as the Task has not been fully created when the @cwd decorator is executed.
See Task.get_working_directory() for more details
Retrieves the working directory set by @cwd for a Task; if not present, it throws KeyError
Sets a working directory value for a specific Task.
Working directories may be declared by Task instance or by their function
Bases: object
TaskWrappers are abstractions of directives that have been applied to a Task, eg @adjust_env().
A few directives are implemented directly in the Dovetail Processor and are not present as TaskWrapper instances:
- @task
- @depends
- @cwd
Directive implementation contains a pre-Task function or a post-Task function or both. The pre- and post-Task functions may interrogate the environment, modify it, perform any calculation or modify the state of execution (eg by calling Execution.skip() or Execution.fail())
Parameters: |
|
---|
Executes the after() method of the wrapper (if any)
Executes the before() method of the wrapper (if any)
Allows a zero-argument directive to register its pre- and post- functions.
Parameters: |
|
---|---|
Returns: | func |
Return type: | function() |
Note
This method has the important side-effect that it creates and registers a TaskWrapper that will be used by the Dovetail engine
Allows a directive with arguments to register its pre- and post- functions.
This method returns a decorator which uses by TaskWrapper.decorate().
Parameters: |
|
---|---|
Returns: | A decorator of the TaskWrapper |
Return type: | function(function) |
The function used to create the NullTask held in dovetail.model.NULL_TASK
py.test tests for config.py
Bases: object
Interface to virtualenv.
The main purpose is to support running the build in:
- An existing virtual environment
- A new virtual environment
- A freshly recreated virtual environment
A script used to bootstrap Dovetail in a virtualenv sub-process
Produce a command line for calling a virtual environment.
Parameters: |
|
---|---|
Returns: | The command line to bootstrap the build in a virtual environment |
Return type: | string |
This is basically the same as the command line which called this, but we remove the virtual environment arguments
Returns the sys.path entry that loaded this module (dovetail)
Returns: | Path to dovetail |
---|---|
Return type: | string |
Returns the command to create a virtualenv environment.
Parameters: |
|
---|---|
Returns: | A command suitable for executing with subprocess.call() |
Return type: | list of string |
Attempts to install and validate virtualenv returning the path to the virtualenv executable.
If the installation fails, the function raises InvalidEnvironment exception.
Returns: | The full path to the newly-created virtualenv executable |
---|---|
Return type: | string |
Raises : | InvalidEnvironment |
Prepare the proposed virtual environment, returning the path to the Python executable to use.
This function will call virtualenv to create the environment if either the environment is not present, or the –clear option was specified.
Parameters: |
|
---|---|
Returns: | The full path to the virtualenv executable under proposed |
Return type: | string |
Raises : |
Validates the virtual environment to ensure it can be used, raising an exception if it is not.
Parameters: |
|
---|---|
Raises : |
Validates whether we can create a virtual environment - can we write to the specified directory?
Parameters: |
|
---|---|
Raises : |
Runs the test in a virtualenv environment, creating and clearing it if necessary.
Parameters: |
|
---|---|
Returns: | The return of the subprocess.call() process |
Return type: | int |
The arguments from the original invocation should be passed untouched and will (after manipulation) be passed to the virtual environment
Creates a bootstrap Python file in a directory, returning the path to the bootstrap file.
Parameters: | directory (string) – Path to directory in which to write the bootstrap |
---|---|
Returns: | Path to the bootstrap.py file |
Return type: | string |