Existing Services

There are many Services in Fedora. Many of these have an interface that we can query and get back information as JSON data. There is documentation here about both the services and the client modules that can access them.

Fedora Account System

FAS is the Fedora Account System. It holds the account data for all of our contributors.

class fedora.client.AccountSystem(base_url='https://admin.fedoraproject.org/accounts/', *args, **kwargs)

An object for querying the Fedora Account System.

The Account System object provides a python API for talking to the Fedora Account System. It abstracts the http requests, cookie handling, and other details so you can concentrate on the methods that are important to your program.

get_config(username, application, attribute)

Return the config entry for the key values.

Parameters:
  • username – Username of the person
  • application – Application for which the config is set
  • attribute – Attribute key to lookup
Raises AppError:
 

if the server returns an exception

Returns:

The unicode string that describes the value. If no entry matched the username, application, and attribute then None is returned.

get_configs_like(username, application, pattern=u'*')

Return the config entries that match the keys and the pattern.

Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.

Parameters:
  • username – Username of the person
  • application – Application for which the config is set
  • pattern – A pattern to select values for. This accepts * as a wildcard character. Default=’*’
Raises AppError:
 

if the server returns an exception

Returns:

A dict mapping attribute to value.

group_by_id(group_id)
Returns a group object based on its id
group_by_name(groupname)
Returns a group object based on its name
group_data(force_refresh=None)

Return administrators/sponsors/users and group type for all groups

Parameters:
  • force_refresh – If true, the returned data will be queried from the database, as opposed to memcached.
Raises AppError:
 

if the query failed on the server

Returns:

A dict mapping group names to the group type and the user IDs of the administrator, sponsors, and users of the group.

New in version 0.3.8.

group_members(groupname)

Return a list of people approved for a group.

This method returns a list of people who are in the requested group. The people are all approved in the group. Unapproved people are not shown. The format of data is:

\[{'username': 'person1', 'role_type': 'user'},
\{'username': 'person2', 'role_type': 'sponsor'}]

role_type can be one of ‘user’, ‘sponsor’, or ‘administrator’.

New in version 0.3.2.

Changed in version 0.3.21: Return a Bunch instead of a DictContainer

insecure
people_by_groupname(groupname)

Return a list of persons for the given groupname.

Parameters:
  • groupname – Name of the group to look up
Returns:

A list of person objects from the group. If the group contains no entries, then an empty list is returned.

people_by_id()

Deprecated Use people_by_key() instead.

Returns a dict relating user IDs to human_name, email, username, and bugzilla email

Changed in version 0.3.21: Return a Bunch instead of a DictContainer

people_by_key(key=u'username', search=u'*', fields=None)

Return a dict of people

Parameters:
  • key – Key by this field. Valid values are ‘id’, ‘username’, or ‘email’. Default is ‘username’
  • search – Pattern to match usernames against. Defaults to the ‘*’ wildcard which matches everyone.
  • fields

    Limit the data returned to a specific list of fields. The default is to retrieve all fields. Valid fields are:

    • affiliation
    • alias_enabled
    • bugzilla_email
    • certificate_serial
    • comments
    • country_code
    • creation
    • email
    • emailtoken
    • facsimile
    • gpg_keyid
    • group_roles
    • human_name
    • id
    • internal_comments
    • ircnick
    • last_seen
    • latitude
    • locale
    • longitude
    • memberships
    • old_password
    • password
    • password_changed
    • passwordtoken
    • postal_address
    • privacy
    • roles
    • ssh_key
    • status
    • status_change
    • telephone
    • timezone
    • unverified_email
    • username

    Note that for most users who access this data, many of these fields will be set to None due to security or privacy settings.

Returns:

a dict relating the key value to the fields.

Changed in version 0.3.21: Return a Bunch instead of a DictContainer

Changed in version 0.3.26: Fixed to return a list with both people who have signed the CLA and have not

people_query(constraints=None, columns=None)

Returns a list of dicts representing database rows

Parameters:
  • constraints – A dictionary specifying WHERE constraints on columns
  • columns – A list of columns to be selected in the query
Raises AppError:
 

if the query failed on the server (most likely because the server was given a bad query)

Returns:

A list of dicts representing database rows (the keys of the dict are the columns requested)

New in version 0.3.12.1.

person_by_id(person_id)
Returns a person object based on its id
person_by_username(username)
Returns a person object based on its username
set_config(username, application, attribute, value)

Set a config entry in FAS for the user.

Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.

Parameters:
  • username – Username of the person
  • application – Application for which the config is set
  • attribute – The name of the config key that we’re setting
  • value – The value to set this to
Raises AppError:
 

if the server returns an exception

user_data()

Return user data for all users in FAS

Note: If the user is not authorized to see password hashes, ‘*’ is returned for the hash.

Raises AppError:
 if the query failed on the server
Returns:A dict mapping user IDs to a username, password hash, SSH public key, email address, and status.

New in version 0.3.8.

user_gencert()
Generate a cert for a user
user_id()
Returns a dict relating user IDs to usernames
verify_password(username, password)

Return whether the username and password pair are valid.

Parameters:
  • username – username to try authenticating
  • password – password for the user
Returns:

True if the username/password are valid. False otherwise.

Package Database

The Package Database holds information about packages in Fedora. It currently has a developer-centric view of packages that concentrates on who the owner is of a particular package.

Plans to add an end-user view to packages is ongoing.

class fedora.client.PackageDB(base_url='https://admin.fedoraproject.org/pkgdb/', *args, **kwargs)

Changed in version 0.3.21: Added PackageDB.add_comaintainers() Added PackageDB.change_owner()

add_comaintainers(owner, comaintainers, pkg_pattern, collectn_name, collectn_ver=None, if_comaint=False)

Add comaintainers to all packagelistings that the owner either is the owner or has approveacls on. Then email comaintainers/owners on those packages that the maintainer has changed the acls.

Parameters:
  • owner – the owner’s username
  • comaintainers – a list of new comaintainers
  • pkg_pattern – a simple pattern for package names
  • collectn_name – limit packages to branches for this distribution.
  • collectn_ver – If given, limit information to this particular version of a distribution.
  • if_comaint – Boolean. If True, then process packagelistings for which owner is also a co-maintainer (i.e., has approveacls).

New in version 0.3.21.

add_package(pkg, owner=None, description=None, branches=None, cc_list=None, comaintainers=None, groups=None)

Add a package to the database.

Parameters:
  • pkg – Name of the package to edit
  • owner – If set, make this person the owner of both branches
  • description – If set, make this the description of both branches
  • branches – List of branches to operate on
  • cc_list – If set, list or tuple of usernames to watch the package.
  • comaintainers – If set, list or tuple of usernames to comaintain the package.
  • groups – If set, list or tuple of group names that can commit to the package.
Raises AppError:
 

If the server returns an error

New in version 0.3.13.

branches
canonical_branch_name(branch)

Change a branch abbreviation into a name and version.

Parameters:
  • branch – branch abbreviation
Return type:

tuple

Returns:

tuple of branch name and branch version.

Example: >>> name, version = canonical_branch_name(‘FC-6’) >>> name Fedora >>> version 6

change_owner(owner, new_owner, pkg_pattern, collectn_name, collectn_ver=None, if_comaint=False)

Change the owner of all packagelistings that the owner either is the owner or has approveacls on. Then email comaintainers/owners on those packages that the owner has changed the owner.

Parameters:
  • owner – the current owner’s username
  • new_owner – the new owner’s username
  • pkg_pattern – a simple pattern for package names
  • collectn_name – limit packages to branches for this distribution.
  • collectn_ver – If given, limit information to this particular version of a distribution.
  • if_comaint – Boolean. If True, then process packagelistings for which owner is also a co-maintainer (i.e., has approveacls).

New in version 0.3.21.

clone_branch(pkg, branch, master, email_log=True)

Set a branch’s permissions from a pre-existing branch.

Parameters:
  • pkg – Name of the package to branch
  • branch

    Branch to clone to. Allowed branch names are listed in COLLECTIONMAP

  • master – Short branch name to clone from. Allowed branch names are listed in COLLECTIONMAP
  • email_log – If False, do not email a copy of the log.
Raises AppError:
 

If the server returns an exceptiom

edit_package(pkg, owner=None, description=None, branches=None, cc_list=None, comaintainers=None, groups=None)

Edit a package.

Parameters:
  • pkg – Name of the package to edit
  • owner – If set, make this person the owner of both branches
  • description – If set, make this the description of both branches
  • branches – List of branches to operate on
  • cc_list – If set, list or tuple of usernames to watch the package.
  • comaintainers – If set, list or tuple of usernames to comaintain the package.
  • groups – If set, list or tuple of group names that can commit to the package.
Raises AppError:
 

If the server returns an error

This method takes information about a package and either edits the package to reflect the changes to information.

Note: This method will be going away in favor of methods that do smaller chunks of work:

  1. A method to add a new branch
  2. A method to edit an existing package
  3. A method to edit an existing branch

New in version 0.3.13.

get_bugzilla_acls()

Return the package attributes used by bugzilla.

Return type:

Bunch

Returns:

Bunch contains information needed to setup bugzilla for every collection. It looks like this: data[collctn][pkg][attribute] where attribute is one of: :owner: FAS username for the owner :qacontact: if the package hasa special qacontact, their userid is listed here :summary: Short description of the package :cclist: list of FAS userids that are watching the package

Example::
>>> print data['Fedora']['bzr']['owner']
'toshio'
>>> print data['Fedora']['bzr']['qacontact']
None
>>> print data['Fedora']['bzr']['summary']
'Friendly distributed version control system'
>>> print data['Fedora']['bzr']['cclist']
{'groups': [], 'people': ['hno', 'shahms', 'toshio']}
>>> data.keys()
['Fedora OLPC', 'Fedora', 'Fedora EPEL']

New in version 0.3.15.

Changed in version 0.3.21: Return Bunch instead of DictContainer

get_collection_list(eol=True)

Retrieve a list of all collections.

Parameters:
  • eol – Default True. If set to False, do not return collections marked eol.
Returns:

list of collections

get_critpath_pkgs(collctn_list=None)

Return names of packages marked critical path.

Parameters:
  • collctn_list – When set to a list of Collection names, only retrieve packages which are marked critpath in any of the collections. Defaults to retrieving critpath packages in all non-EOL releases
Return type:

Bunch

Returns:

Keys of the returned dict are collection simple names. The values are lists of package names that are marked critpath

New in version 0.3.17.

Changed in version 0.3.21: Return Bunch instead of DictContainer

get_notify_acls(collctn_name=None, collctn_ver=None, eol=False)

Return the package attibutes used by notify

Parameters:
  • collctn_name – Limit the packages to those in collection with this name. for instance, ‘Fedora’, ‘Fedora EPEL’, ‘Fedora OLPC’.
  • collctn_ver – If collctn_name is specified, this allows you to also limit to a specific version of a collection. If collctn_name isn’t specified, this option does nothing.
  • eol – If eol is set to True, include eol distributions in the notify list. Default: False
  • role_list – Note, this will not do anything until pkgdb-0.5. List of roles that the user must have the acls for in order to be included. Valid roles are: owner, comaintainer, committer, bzwatcher, and vcswatcher
Return type:

Bunch

Returns:

Bunch keyed on package name. Each entry has a list of people to be notified for this package.

New in version 0.3.15.

Changed in version 0.3.21: Return Bunch instead of DictContainer

get_owners(package, collctn_name=None, collctn_ver=None, collection=None, collection_ver=None)

Retrieve the ownership information for a package.

Parameters:
  • package – Name of the package to retrieve package information about.
  • collctn_name – Limit the returned information to this collection (‘Fedora’, ‘Fedora EPEL’, Fedora OLPC’, etc)
  • collctn_ver – If collection is specified, further limit to this version of the collection.
  • collection – old/deprecated argument; use collctn_name
Kward collection_ver:
 

old/deprecated argument; use collctn_ver

Raises AppError:
 

If the server returns an error

Return type:

Bunch

Returns:

dict of ownership information for the package

Changed in version 0.3.17: Rename collection and collection_ver to collctn_name and collctn_ver

Changed in version 0.3.21: Return Bunch instead of DictContainer

get_package_info(pkg, branch=None)

Get information about the package.

Parameters:
  • pkg – Name of the package
  • branch – If given, restrict information returned to this branch Allowed branches are listed in COLLECTIONMAP
Raises AppError:
 

If the server returns an exceptiom

Returns:

Package ownership information

Return type:

Bunch

Changed in version 0.3.21: Return Bunch instead of DictContainer

get_package_list(collctn=None, collectn=None)

Retrieve a list of all package names in a collection.

Parameters:
  • collctn – Collection to look for packages in. This is a collctn shortname like ‘devel’ or ‘F-13’. If unset, return packages in all collections
  • collectnDeprecated. Please use collctn instead
Returns:

list of package names present in the collection.

New in version 0.3.15.

Changed in version 0.3.17: Rename collectn to collctn

get_vcs_acls()

Return the acls for the version control system.

Note: the return values from this function will be changing when the PackageDB updates to 0.5.x. The return data will look like this:

data[pkg][branch].people
data[pkg][branch].groups
Return type:

Bunch

Returns:

Bunch representing the vcs acls for every person. It looks like this: data[pkg][branch][‘commit’].people list of users who can commit to the package. Example:

>>> print data['bzr']['devel']['commit'].people
['toshio', 'hno', 'shahms', 'toshio']
>>> print data['bzr']['devel']['commit'].groups
['provenpackager']

New in version 0.3.15.

Changed in version 0.3.21: Return Bunch instead of DictContainer

mass_branch(branch)

Branch all unblocked packages for a new release.

Mass branching always works against the devel branch.

Parameters:
  • branch – Branch name to create branches for. Names are listed in COLLECTIONMAP
Raises AppError:
 

If the server returns an exceptiom. The ‘extras’ attribute will contain a list of unbranched packages if some of the packages were branched

orphan_packages()

List the packages which are orphaned

Returns:List of pkgs which are orphaned in any non-EOL release.
remove_user(username, pkg_name, collctn_list=None, collectn_list=None)

Remove user from a package

Parameters:
  • username – Name of user to remove from the package
  • pkg_name – Name of the package
  • collctn_list – list of collection simple names like ‘F-10’,’devel’. Default: None which means user removed from all collections associated with the package.
  • collectn_listDeprecated Use collctn_list instead.
Returns:

status code from the request

New in version 0.3.12.

Changed in version 0.3.17: Rename collectn_list to collctn_list

set_critpath(pkg_list=None, critpath=True, collctn_list=None, reset=False)

Mark packages as being in the critical path.

Critical path packages are subject to more testing or stringency of criteria for updating when a release occurs.

Parameters:
  • pkg_list – List of package names to set as critical path. Default: all packages within collectn_list
  • critpath – Boolean. True (default) means this package is in the critical path. False means that it should be taken out
  • collctn_list – List of collection shortnames that this change will be applied on. The default is all non-EOL collections.
  • reset – If True, clear the critpath flag from all packages in collectn_list before setting critpath on the packages in pkg_list. Default is False

New in version 0.3.17.

user_packages(username, acls=None, eol=False)

Retrieve information about the packages a user owns

Parameters:
  • username – user whose packages we want
  • acls – list of acls that the user must have on the package. The list can include ‘owner’, ‘approveacls’, ‘commit’, ‘watchbugzilla’, ‘watchcommits’. Default is to select for all acls.
  • eol – If True, then include ownership of packages in End of Life distributions. If False, only include ownership of packages in active releases.
Returns:

packages that the user has acls on

New in version 0.3.14.

Bodhi, the Update Server

Bodhi is used to push updates from the build system to the download repositories. It lets packagers send packages to the testing repository or to the update repository.

class fedora.client.BodhiClient(base_url='https://admin.fedoraproject.org/updates/', useragent='Fedora Bodhi Client/0.5.1', *args, **kwargs)
candidates()

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(update, comment, karma=0, email=None)

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 – Whether or not to trigger email notifications
delete(update)

Delete an update.

Parameters:
  • update – The title of the update to delete
get_koji_session(login=True)
Return an authenticated koji session
get_releases()

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"}]}
koji_session
latest_builds(package)

Get a list of the latest builds for this package.

Parameters:
  • package – package name to find builds for.
Returns:

a dictionary of the release dist tag to the latest build.

New in version 0.3.2.

masher()
Return the status of bodhi’s masher
parse_file(input_file)

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.

push()
Return a list of requests
push_updates(updates)

Push a list of updates.

Parameters:
  • updates – A list of update titles to push.
query(release=None, status=None, type_=None, bugs=None, request=None, mine=None, package=None, username=None, limit=10)

Query bodhi for a list of updates.

Parameters:
  • release – The release that you wish to query updates for.
  • status – The update status (pending, testing, stable, obsolete)
  • 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.
  • package – A package name or a name-version-release.
  • limit – The maximum number of updates to display. Default: 10.
request(update, request)

Request an update state change.

Parameters:
  • update – The title of the update
  • request – The request (testing, stable, obsolete)
save(builds='', type_='', bugs='', notes='', request='testing', close_bugs=True, suggest_reboot=False, inheritance=False, autokarma=True, stable_karma=3, unstable_karma=-3, edited='')

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_reboot – Suggest that the user reboot after update.
  • 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.
testable()

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.

update_str(update, minimal=False)

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.