Core API Reference¶
Koji Smoky Dingo - Client utilities for working with the Koji build system
- author:
Christopher O'Brien <obriencj@gmail.com>
- license:
GPL v3
- class AnonClientSession(profile='koji')[source]¶
Bases:
ProfileClientSession
A
koji.ClientSession
which loads profile config information and which can be used via thewith
keyword.Suitable for working with anonymous commands which do not require authentication. Does not authenticate, and will only connect lazily.
- Since:
1.0
- Parameters:
profile (str) -- name of the koji profile to load from local configuration locations
- exception BadDingo[source]¶
Bases:
Exception
Generalized base class for exceptions raised from kojismokydingo. This class and its subclasses are used to combine a fixed complaint string with some specific information. This is a convenience primarily for the CLI, but can also be used to track more detailed situations where a requested data type wasn't present on the koji hub, rather than just working with
koji.GenericError
- Since:
1.0
Bases:
BadDingo
A given feature isn't available due to the version on the koji hub
- class ManagedClientSession(baseurl, opts=None, sinfo=None, auth_method=None)[source]¶
Bases:
ClientSession
A
koji.ClientSession
that can be used as via thewith
keyword to provide a managed session that will handle authenticated login and logout.- Since:
1.0
- Parameters:
- activate()[source]¶
Invokes
koji_cli.lib.activate_session
with this session's options, which will trigger the appropriate login method.- Since:
2.0
- property logger¶
- exception NoSuchContentGenerator[source]¶
Bases:
BadDingo
A content generator was not found
- Since:
1.0
- exception NotPermitted[source]¶
Bases:
BadDingo
A required permission was not associated with the currently logged in user account.
- class ProfileClientSession(profile='koji')[source]¶
Bases:
ManagedClientSession
A
koji.ClientSession
which loads profile config information and which can be used via thawith
keyword.- Since:
1.0
- Parameters:
profile (str) -- name of the koji profile to load from local configuration locations
- as_archiveinfo(session, archive)[source]¶
Coerces an archive value into an archive info dict.
- If archive is an:
int, will attempt to load as an archive ID
str, will attempt to load as the first-found archive matching the given filename
dict, will presume already an archive info
- Parameters:
session (ClientSession) -- active koji session
archive (int | str | ArchiveInfo) -- value to lookup
- Raises:
NoSuchArchive -- if the archive value could not be resolved into an archive info dict
- Since:
1.0
- Return type:
- as_buildinfo(session, build)[source]¶
Coerces a build value into a koji build info dict.
- If build is an
int, will attempt to load as a build ID
str, will attempt to load as an NVR
dict, will presume already a build info
- Parameters:
- Raises:
NoSuchBuild -- if the build value could not be resolved into a build info dict
- Since:
1.0
- Return type:
- as_channelinfo(session, channel)[source]¶
Coerces a channel value into a koji channel info dict.
- If channel is an
int, will attempt to load as a channel ID
str, will attempt to load as a channel name
dict, will presume already a channel info
- Parameters:
session (ClientSession) -- an active koji client session
channel (int | str | ChannelInfo) -- value to lookup
- Raises:
NoSuchChannel -- if the channel value could not be resolved into a channel info dict
- Since:
1.1
- Return type:
- as_hostinfo(session, host)[source]¶
Coerces a host value into a host info dict.
- If host is an:
int, will attempt to load as a host ID
str, will attempt to load as a host name
dict, will presume already a host info
- Parameters:
- Raises:
NoSuchHost -- if the host value could not be resolved into a host info dict
- Since:
1.0
- Return type:
- as_packageinfo(session, pkg)[source]¶
Coerces a host value into a host info dict.
- If pkg is an:
int, will attempt to load as a package ID
str, will attempt to load as a package name
dict, will presume already a package info
- Parameters:
session (ClientSession) -- an active koji client session
pkg (int | str | PackageInfo) -- value to lookup
- Raises:
NoSuchPackage -- if the pkg value could not be resolved into a package info dict
- Since:
1.1
- Return type:
- as_repoinfo(session, repo)[source]¶
Coerces a repo value into a Repo info dict.
- If repo is an:
dict with name, will attempt to load the current repo from a tag by that name
str, will attempt to load the current repo from a tag by name
int, will attempt to load the repo by ID
dict, will presume already a repo info
- as_rpminfo(session, rpm)[source]¶
Coerces a host value into a RPM info dict.
- If rpm is specified as an:
int, will attempt to load as a RPM ID
str, will attempt to load as a RPM NVRA
dict, will presume already an RPM info
- as_taginfo(session, tag)[source]¶
Coerces a tag value into a koji tag info dict.
- If tag is an
int, will attempt to load as a tag ID
str, will attempt to load as a tag name
dict, will presume already a tag info
- as_targetinfo(session, target)[source]¶
Coerces a target value into a koji target info dict.
- If target is an
int, will attempt to load as a target ID
str, will attempt to load as a target name
dict, will presume already a target info
- Parameters:
session (ClientSession) -- active koji session
target (int | str | TargetInfo) -- value to lookup
- Raises:
NoSuchTarget -- if the target value could not be resolved into a target info dict
- Since:
1.0
- Return type:
- as_taskinfo(session, task)[source]¶
Coerces a task value into a koji task info dict.
- If task is an
int, will attempt to load as a task ID
dict, will presume already a task info
Note that if this function does attempt to load a task, it will request it with the task's request data as well.
- Parameters:
- Raises:
NoSuchTask -- if the task value could not be resolved into a task info dict
- Since:
1.0
- Return type:
- as_userinfo(session, user)[source]¶
Resolves user to a userinfo dict.
If user is a str or int, then getUser will be invoked. If user is already a dict, it's presumed to be a userinfo already and it's returned unaltered.
- Parameters:
- Raises:
NoSuchUser -- when user cannot be found
- Since:
1.0
- Return type:
- bulk_load(session, loadfn, keys, err=True, size=100, results=None)[source]¶
Generic bulk loading function. Invokes the given
loadfn
on each key inkeys
using chunking multicalls limited to the specified size.Returns a dict associating the individual keys with the returned value of loadfn. If
results
is specified, it must support dict-like assignment via an update method, and will be used in place of a newly allocated dict to store and return the results.- Parameters:
session (ClientSession) -- an active koji client session
loadfn (Callable[[Any], Any]) -- The loading function, to be invoked in a multicall arrangement. Will be called once with each given key from
keys
keys (Iterable[Any]) -- The sequence of keys to be used to invoke
loadfn
. These keys need to be individually hashable, or theresults
value needs to be specified with an instance that accepts assignmnet using these values as the key.err (bool) -- Whether to raise any underlying fault returns as exceptions. Default,
True
size (int) -- How many calls to
loadfn
to chunk up for each multicall. Default,100
results (dict | None) -- storage for
loadfn
results. If specified, must support item assignment (like a dict) via an update method, and it will be populated and then used as the return value for this function. Default, a new dict will be allocated.
- Raises:
koji.GenericError -- if
err
isTrue
and an issue occurrs while invoking theloadfn
- Since:
1.0
- Return type:
- bulk_load_build_archives(session, build_ids, btype=None, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the archives of builds via
session.listArchives
for each build ID in build_ids.Returns a dict associating the individual build IDs with their resulting archive lists.
If results is non-None, it must support dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_build_rpms(session, build_ids, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the RPMs of builds via
session.listRPMS
for each build ID in build_ids.Returns a dict associating the individual build IDs with their resulting RPM lists.
If results is non-None, it must support a dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_buildroot_archives(session, buildroot_ids, btype=None, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the archives of buildroots via
session.listArchives
for each buildroot ID in buildrood_ids.Returns a dict associating the individual buildroot IDs with their resulting archive lists.
If results is non-None, it must support dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_buildroot_rpms(session, buildroot_ids, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the RPMs of buildroots via
session.listRPMs
for each buildroot ID in buildrood_ids.Returns a dict associating the individual buildroot IDs with their resulting RPM lists.
If results is non-None, it must support dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_buildroots(session, broot_ids, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the buildroot data via
session.getBuildroot
for each ID in broot_ids.Returns a dict associating the individual buildroot IDs with their resulting buildroot info dicts.
If results is non-None, it must support a dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_builds(session, nvrs, err=True, size=100, results=None)[source]¶
Load many buildinfo dicts from a koji client session and a sequence of NVRs.
Returns a dict associating the individual NVRs with their resulting buildinfo.
If err is True (default) then any missing build info will raise a
NoSuchBuild
exception. If err is False, then a None will be substituted into the ordered dict for the result.If results is non-None, it must support dict assignment, and will be used in place of a newly allocated dict to store and return the results.
- Parameters:
nvrs (Iterable[str | int]) -- Sequence of build NVRs or build IDs to load
err (bool) -- Raise an exception if an NVR fails to load. Default, True.
size (int) -- Count of NVRs to load in a single multicall. Default, 100
results (dict | None) -- mapping to store the results in. Default, produce a new dict
session (ClientSession)
- Raises:
NoSuchBuild -- if err is True and any of the given builds could not be loaded
- Since:
1.0
- Return type:
- bulk_load_rpm_sigs(session, rpm_ids, size=100, results=None)[source]¶
Set up a chunking multicall to fetch the signatures for a list of RPM via
session.queryRPMSigs
for each ID in rpm_ids.Returns a dict associating the individual RPM IDs with their resulting RPM signature lists.
If results is non-None, it must support a dict-like update method, and will be used in place of a newly allocated dict to store and return the results.
- bulk_load_tags(session, tags, err=True, size=100, results=None)[source]¶
Load many taginfo dicts from tag names or IDs.
- Parameters:
- Raises:
NoSuchTag -- if err is True and a tag couldn't be loaded
- Since:
1.0
- Return type:
- bulk_load_tasks(session, task_ids, request=False, err=True, size=100, results=None)[source]¶
Load many taskinfo dicts from a koji client session and a sequence of task IDs.
Returns a dict associating the individual IDs with their resulting taskinfo.
- Parameters:
session (ClientSession) -- an active koji client session
request (bool) -- if True then load the task's request data as well. Default, False
err (bool) -- raise an exception if a task fails to load. Default, True
size (int) -- count of tasks to load in a single multicall. Default, 100
results (dict | None) -- mapping to store the results in. Default, produce a new dict
- Raises:
NoSuchTask -- if err is True and a task couldn't be loaded
- Since:
1.0
- Return type:
- bulk_load_users(session, users, err=True, size=100, results=None)[source]¶
Load many userinfo dicts from a koji client session and a sequence of user identifiers.
Returns a dict associating the individual identifiers with their resulting userinfo.
If err is True (default) then any missing user info will raise a NoSuchUser exception. If err is False, then a None will be substituted into the ordered dict for the result.
If results is non-None, it must support dict assignment, and will be used in place of a newly allocated dict to store and return the results.
- Parameters:
- Raises:
NoSuchUser -- if err is True and a user could not be loaded
- Since:
1.0
- Return type:
- hub_version(session)[source]¶
Wrapper for
session.getKojiVersion
which caches the results on the session and splits the value into a tuple of ints for easy comparison.If the getKojiVersion method isn't implemented on the hub, we presume that we're version 1.22
(1, 22)
which is the last version before the getKojiVersion API was added.If used with koji hub and client >= 1.35 then this value is farmed from the Koji-Version header of XMLRPC responses, rather than directly calling getKojiVersion.
- iter_bulk_load(session, loadfn, keys, err=True, size=100)[source]¶
Generic bulk loading generator. Invokes the given loadfn on each key in keys using chunking multicalls limited to the specified size.
Yields (key, result) pairs in order.
If err is True (default) then any faults will raise an exception. If err is False, then a None will be substituted as the result for the failing key.
- Parameters:
session (ClientSession) -- The koji session
loadfn (Callable[[Any], Any]) -- The loading function, to be invoked in a multicall arrangement. Will be called once with each given key from keys
keys (Iterable[KT]) -- The sequence of keys to be used to invoke loadfn.
err (bool) -- Whether to raise any underlying fault returns as exceptions. Default, True
size (int) -- How many calls to loadfn to chunk up for each multicall. Default, 100
- Raises:
koji.GenericError -- if err is True and an issue occurrs while invoking the loadfn
- Since:
1.0
- Return type:
- version_check(session, minimum=(1, 23))[source]¶
Verifies that the requested minimum version is met compared against session.getKojiVersion.
If the getKojiVersion method isn't implemented on the hub, we presume that we're version 1.22 (the last version before getKojiVersion was added). Because of this, checking for minimum versions lower than 1.23 will always return True.
Version is specified as a tuple of integers, eg. 1.23 is
(1, 23)
- version_require(session, minimum=(1, 23), message=None)[source]¶
Verifies that the requested minimum version is met compared against
session.getKojiVersion()
If the getKojiVersion method isn't implemented on the hub, we presume that we're version 1.22 (the last version before getKojiVersion was added). Because of this, checking for minimum versions lower than 1.23 will always return True.
Version is specified as a tuple of integers, eg. 1.23 is
(1, 23)
If the version requirement is not met, a
FeatureUnavailable
exception is raised, with the given message. If message is not provided, a simple one is constructed based on the minimum value.- Parameters:
- Raises:
FeatureUnavailable -- If the minimum version is not met
- Since:
1.0
- Return type: