Python bindings

This module provides Python bindings to the Bodhi REST API.

class bodhi.client.bindings.BodhiClient(base_url='https://bodhi.fedoraproject.org/', username=None, password=None, staging=False, **kwargs)[source]

Bases: fedora.client.openidbaseclient.OpenIdBaseClient

candidates()[source]

Get a list list of update candidates.

This method is a generator that returns a list of koji builds that could potentially be pushed as updates.

comment(*args, **kwargs)[source]

Add a comment to an update.

Parameters:
  • update – The title of the update comment on.
  • comment – The text of the comment.
  • karma – The karma of this comment (-1, 0, 1)
  • email – Email address for an anonymous user. if an email address is supplied here, the comment is added as anonymous (i.e. not a logged in user)
csrf(*args, **kwargs)[source]

Return the CSRF token if alread aquired, otherwise login, get a CSRF, cache it, and return.

If there is already a CSRF token, this method returns it.

If there is not, this method ensures that we know the username, logs in if we aren’t already logged in aquires and caches a CSRF token, and returns it.

get_koji_session()[source]

Return an authenticated koji session

get_releases(*args, **kwargs)[source]

Return a list of bodhi releases.

This method returns a dictionary in the following format:

{"releases": [
    {"dist_tag": "dist-f12", "id_prefix": "FEDORA",
     "locked": false, "name": "F12", "long_name": "Fedora 12"}]}
init_username()[source]

Check to see if the username attribute on self is set, and set if if it is not.

If the username is already set on self, return.

If the username is not already set on self, attempt to find if there is a username that has successfully authenticated in the Fedora session file. If that doesn’t work, fall back to prompting the terminal for a username. Once the username has been set, re-run self._load_cookies() so we can re-use the user’s last session.

koji_session

Return an authenticated koji session

latest_builds(*args, **kwargs)[source]
list_overrides(*args, **kwargs)[source]

List buildroot overrides.

Parameters:
  • user – A username whose buildroot overrides you want returned.
  • package – package name to filter buildroot overrides by.
  • expired – True to return only expired overrides, False for only Active.
  • releases – release shortnames to filter buildroot overrides by.
static override_str(override, minimal=True)[source]

Return a string representation of a given override dictionary.

Parameters:
  • override – An override dictionary.
  • minimal – Return a minimal one-line representation of the update.
parse_file(input_file)[source]

Parse an update template file.

Parameters:input_file – The filename of the update template.

Returns an array of dictionaries of parsed update values which can be directly passed to the save method.

password
query(*args, **kwargs)[source]

Query bodhi for a list of updates.

Parameters:
  • content_type – A content type (rpm, module) to limit the query to.
  • releases – A list of releases that you wish to query updates for.
  • status – The update status (pending, testing, stable, obsolete, unpushed, processing)
  • type – The type of this update: security, bugfix, enhancement, and newpackage.
  • bugs – A list of Red Hat Bugzilla ID’s
  • request – An update request to query for testing, stable, unpush, obsolete or None.
  • mine – If True, only query the users updates. Default: False.
  • packages – A space or comma delimited list of package names
  • limit – A deprecated argument, sets rows_per_page. See its docstring for more info.
  • approved_before – A datetime string
  • approved_since – A datetime string
  • builds – A space or comma delimited string of build nvrs
  • critpath – A boolean to query only critical path updates
  • cves – Filter by CVE IDs
  • locked – A boolean to filter only locked updates
  • modified_before – A datetime string to query updates that have been modified before a certain time.
  • modified_since – A datetime string to query updates that have been modified since a certain time.
  • pushed – A boolean to filter only pushed updates
  • pushed_before – A datetime string to filter updates pushed before a certain time.
  • pushed_since – A datetime string to filter updates pushed since a certain time.
  • severity – A severity type to filter by (unspecified, urgent, high, medium, low)
  • submitted_before – A datetime string to filter updates submitted before a certain time.
  • submitted_since – A datetime string to filter updates submitted after a certain time.
  • suggest – Query for updates that suggest a user restart (logout, reboot)
  • user – Query for updates submitted by a specific user.
  • rows_per_page – Limit the results to a certain number of rows per page (min:1 max: 100 default: 20)
  • page – Return a specific page of results
request(*args, **kwargs)[source]

Request an update state change.

Parameters:
  • update – The title of the update
  • request – The request (testing, stable, obsolete, unpush, revoke)
save(*args, **kwargs)[source]

Save an update.

This entails either creating a new update, or editing an existing one. To edit an existing update, you must specify the update title in the edited keyword argument.

Parameters:
  • builds – A list of koji builds for this update.
  • type – The type of this update: security, bugfix, enhancement, and newpackage.
  • bugs – A list of Red Hat Bugzilla ID’s associated with this update.
  • notes – Details as to why this update exists.
  • request – Request for this update to change state, either to testing, stable, unpush, obsolete or None.
  • close_bugs – Close bugs when update is stable
  • suggest – Suggest that the user reboot or logout after update. (reboot, logout)
  • inheritance – Follow koji build inheritance, which may result in this update being pushed out to additional releases.
  • autokarma – Allow bodhi to automatically change the state of this update based on the karma from user feedback. It will push your update to stable once it reaches the stable_karma and unpush your update when reaching unstable_karma.
  • stable_karma – The upper threshold for marking an update as stable.
  • unstable_karma – The lower threshold for unpushing an update.
  • edited – The update title of the existing update that we are editing.
  • severity – The severity of this update (urgent, high, medium, low)
  • requirements – A list of required Taskotron tests that must pass for this update to reach stable. (e.g. dist.rpmdeplint, dist.upgradepath, dist.rpmlint, etc)
  • require_bugs – A boolean to require that all of the bugs in your update have been confirmed by testers.
  • require_testcases – A boolean to require that this update passes all test cases before reaching stable.
save_override(*args, **kwargs)[source]

Save a buildroot override.

This entails either creating a new buildroot override, or editing an existing one.

Parameters:
  • nvr – A nvr of a koji build.
  • duration – Number of days from now that this override should expire.
  • notes – Notes about why this override is in place.
Kwargs edit:

A boolean to edit an existing override.

Kwargs expired:

A boolean to expire an override.

testable()[source]

Get a list of installed testing updates.

This method is a generate that yields packages that you currently have installed that you have yet to test and provide feedback for.

Only works on systems with dnf.

update_str(update, minimal=False)[source]

Return a string representation of a given update dictionary.

Parameters:
  • update – An update dictionary, acquired by the list method.
  • minimal – Return a minimal one-line representation of the update.
exception bodhi.client.bindings.BodhiClientException[source]

Bases: fedora.client.FedoraClientError

exception bodhi.client.bindings.UpdateNotFound(update)[source]

Bases: bodhi.client.bindings.BodhiClientException

bodhi.client.bindings.errorhandled(method)[source]

A decorator for BodhiClient that raises exceptions on failure.