This isn’t final API documentation, more of an example of how we can do API docs.
Once more of our code is using sphinx-style docs, we can start finalizing the format for this page.
Note that the docs here are for libtaskotron library functions and don’t include directives or task yaml details.
Utility functions for dealing with Bodhi
Helper Bodhi methods.
Variables: | client (fedora.client.BodhiClient) – Bodhi client instance |
---|
Create a new BodhiUtils instance.
Parameters: | client – custom BodhiClient instance. If None, a default BodhiClient instance is used. |
---|
Find matching Bodhi updates for provided builds.
Parameters: |
|
---|---|
Returns: | a tuple of two dictionaries:
|
Raises TaskotronValueError: | |
if builds type is incorrect |
Get the last Bodhi update matching criteria.
Parameters: | package (str) – package NVR or package name or update title or update ID Note Only NVR allowed, not NEVR. See https://fedorahosted.org/bodhi/ticket/592. |
---|---|
Returns: | most recent Bodhi update object matching criteria, or None when no update is found. |
Return type: | bunch.Bunch |
Helper tools for managing check status, outcome, and output.
Class encompassing everything related to the outcome of a check run. It contains convenience methods for tracking, evaluating and reporting check results.
For some checks, it’s trivial to parse its output at the end of its execution and evaluate the results. For some, however, it’s much easier to do this continuously during check execution. This is especially true for multi-item checks (a single check providing results for many items - builds, updates, etc). That’s when this class comes very handy (it can be used even for the simple use cases, of course).
Variables: |
|
---|
Tells whether the check outcome is set to one of the broken states (i.e. ABORTED or CRASHED).
Compare two outcomes according to outcome_priority and return -1/0/1 if outcome1 has lower/equal/higher priority than outcome2.
Parameters: |
|
---|---|
Raises TaskotronValueError: | |
if any of the outcome keywords are not specified in outcome_priority |
Create a string containing a sum of all outcomes, like this: 3 PASSED, 1 INFO, 2 FAILED
Parameters: | outcomes – either one CheckDetail instance or an iterable of CheckDetails or an iterable of outcome strings |
---|
Add a string to the output, and print it optionally as well.
This is just a convenience method for most common use case, you can of course always access and modify output directly, and print or use logging facilities directly as well. This combines both into a single call.
Parameters: |
|
---|
Update outcome with the provided value only and only if it has a higher priority than its current value (according to outcome_priority). Otherwise this call does nothing.
This is useful if your check performs a number of ‘sub-tasks’, each passing or failing, and you want to final outcome to be the worst/most serious one of those. You can just keep calling update_outcome() and the highest priority outcome type will be stored at outcome at the end.
Parameters: | outcome (str) – the outcome value to assign to outcome if it has a higher priority than its current value. Handles None values gracefully (no action). |
---|---|
Raises TaskotronValueError: | |
if any of the outcome keywords are not specified in outcome_priority |
Enum for different types of CheckDetail.report_type
Generate TAP output used for reporting to ResultsDB.
Parameters: | check_details – any number of CheckDetail instances |
---|---|
Returns: | TAP output with results for every CheckDetail instance provided |
Return type: | str |
Raises TaskotronValueError: | |
if CheckDetail.item is empty for any parameter provided |
Example output:
TAP Version 13
1..1
ok - $CHECKNAME for Koji build xchat-0.5-1.fc20
---
details:
output: |-
xchat.x86_64: W: file-not-utf8 /usr/share/doc/xchat/ChangeLog
xchat.x86_64: W: non-conffile-in-etc /etc/gconf/schemas/apps.schemas
xchat.x86_64: W: no-manual-page-for-binary xchat
item: xchat-0.5-1.fc20
outcome: PASSED
summary: 5 ERRORS, 10 WARNINGS
type: koji_build
...
Parses TAP and returns a list of CheckDetails.
Parameters: | source (str) – TAP-formatted text |
---|---|
Raises TaskotronValueError: | |
if TAP syntax is incorrect |
Global configuration for Taskotron and relevant helper methods.
A list of directories where config files are stored. The config files are loaded from these locations in the specified order, and only the first config file found is used (further locations are ignored). The first location is dynamic, relative to the package location and it reflects the usual config location in a git checkout.
the name of our configuration file
environment variable name for setting config profile
Get the Config instance. This method is implemented using the singleton pattern - you will always receive the same instance, which will get auto-initialized on the first method call.
Returns: | either Config or its subclass, depending on taskotron profile used. |
---|---|
Raises TaskotronConfigError: | |
if config file parsing and handling failed |
This includes the default values for Taskotron configuration. This is automatically loaded by config.py and then overridden by values from config files available in system-wide location.
Global configuration for Taskotron (development profile).
The documentation for individual options is available in the config files (unless they’re not present in the config files, then they’re documented here).
Implementation notes:
Configuration for production profile. Inherits values from Config and overrides some. Read Config documentation.
This module contains custom Taskotron exceptions
All errors related to Taskotron config files
All errors related to Taskotron directives
Common ancestor for Taskotron related exceptions
All network and remote-server related errors
Taskotron-specific ValueError
Error in YAML config file of the executed check
Download a file.
Parameters: |
|
---|---|
Returns: | file path of the downloaded file |
Return type: | str |
Raises TaskotronRemoteError: | |
if download fails or directory can’t be created |
Get a new instance of URLGrabber that is reasonably configured (progress bar when in terminal, automatic retries, connection timeout, etc)
Parameters: | kwargs – additional kwargs to add to the URLGrabber constructor |
---|---|
Returns: | urlgrabber.grabber.URLGrabber instance |
This is the same as os.makedirs(), but does not raise an exception when the destination directory already exists.
Raises OSError: | if directory doesn’t exist and can’t be created |
---|
Utility methods related to Koji
Helper Koji methods.
Variables: | session (koji.ClientSession) – Koji client session |
---|
Create a new KojiClient
Parameters: | koji_session (koji.ClientSession) – an existing Koji session instance or None if you want a new default session to be created |
---|
Parameters: |
|
---|---|
Returns: | list of local filenames of the grabbed RPMs |
Return type: | list of str |
Raises TaskotronRemoteError: | |
if downloading failed |
Downloads all RPMs of all NVRs tagged by a specific Koji tag.
Parameters: |
|
---|---|
Raises TaskotronRemoteError: | |
if downloading failed |
Get list of URLs for RPMs corresponding to a build.
Parameters: |
|
---|
Extract RPM version identifier in NEVR format from Koji build object
Parameters: | build (dict) – Koji buildinfo dictionary (as returned e.g. from koji.getBuild()) |
---|---|
Returns: | NEVR string; epoch is included when non-zero, otherwise omitted |
Raises TaskotronValueError: | |
if build is of incorrect type |
Setup a logger
Parameters: |
|
---|
A collection of convenience methods related to Python base libraries.
Decide whether obj is an Iterable (you can traverse through its elements - e.g. list, tuple, set, even dict), but not basestring (which satisfies most collections’ requirements, but we don’t often want to consider as a collection). You can also verify the types of items in the collection.
Parameters: |
|
---|---|
Returns: | whether obj is iterable but not a string, and whether obj contains only item_type items |
Return type: | bool |
Raises TaskotronValueError: | |
if you provide invalid parameter value |
This has the same functionality and basic arguments as iterable() (read its documentation), but decides whether obj is a Sequence (ordered and indexable collection - e.g. list or tuple, but not set or dict).
Parameters: | mutable (bool) – if True, the obj must be a mutable sequence (e.g. list, but not tuple) |
---|
Utility methods related to RPM
This returns the ‘base’ architecture identifier for a specified architecture (e.g. i386 for i[3-6]86), to be used by YUM etc.
Parameters: | arch (str) – an architecture to be converted to a basearch. If None, then the arch of the current machine is used. |
---|---|
Returns: | basearch, or arch if no basearch was found for it |
Return type: | str |
Compare two RPM version identifiers in NEVR format.
Parameters: |
|
---|---|
Returns: | -1/0/1 if nevr1 < nevr2 / nevr1 == nevr2 / nevr1 > nevr2 |
Return type: | int |
Raises TaskotronValueError: | |
if name in nevr1 doesn’t match name in nevr2 |
Parse and convert an RPM package version string into a different format. String identifiers: N - name, E - epoch, V - version, R - release, A - architecture.
Parameters: |
|
---|---|
Returns: | string based on the specified format, or integer if fmt='e' |
Raises TaskotronValueError: | |
if fmt value is not supported |
Processes raw input args and converts them into specific data types that can be used by tasks. This includes e.g. creating new args based on (item, item_type) pairs, or adjusting selected architecture.
Parameters: | args (dict) – dictionary of raw arguments |
---|---|
Returns: | dict of args with appended specific data |
A wrapper object for yumrepoinfo.conf to access its information easily
This class is a wrapper for easily accessing repoinfo.conf file.
Parameters: |
|
---|---|
Raises TaskotronConfigError: | |
if no YUM repositories data is found (empty or non-existent config file). It’s not raised if you specifically request no data to load (filelist=[]). |
Get the list of all supported architectures for a repo
Parameters: | reponame (str) – repository name |
---|
Get a specific key value from a repo
Parameters: |
|
---|---|
Raises TaskotronConfigError: | |
if the key can’t be retrieved (e.g. wrong key or repo name) |
Get the list of stable (supported) Fedora releases.
Given a repo name, return the yumrepoinfo dict with keys: arches, parents, tag, url, path and name
Parameters: | reponame (str) – repository name |
---|---|
Return type: | dict |
Given a Koji tag, return the corresponding repo dict.
Parameters: | tag (str) – a koji tag, e.g. f20-updates. Note: rawhide is not used as a Koji tag, use number identifier instead or use repo('rawhide')['tag'] to discover it first. |
---|---|
Returns: | repo dict as from repo(), or None if no such Koji tag is found |
Get the list of all known repository names.
Go through the repo hiearchy and find the top parent for a repo
Parameters: | reponame (str) – repository name |
---|---|
Returns: | the top parent reponame. If reponame doesn’t have any parent, its name is returned (it’s its own top parent) |
Return type: | str |
Raises TaskotronConfigError: | |
if infinite parent loop detected |
Get YumRepoInfo instance. This method is implemented using the singleton pattern - you will always receive the same instance, which will get auto-initialized on the first method call.
Parameters: | arch (str) – architecture to return the YumRepoInfo for. It’s always converted to basearch. If None, then local machine arch is used. |
---|---|
Returns: | shared YumRepoInfo instance |
Raises TaskotronConfigError: | |
if file config parsing and handling failed |