#2979 Add a utility function to watch builds
Closed by tkopecek. Opened by oturpe.
oturpe/koji watch-builds-binding  into  master

Download 2979.patch

External tools that interact with Koji
need to wait for builds to appear in a repo.
For example, Fedora cli tools 'bodhi' and 'fedpkg'
can create buildroot overrides,
which only become useful
after the override's build appears in the correct repo.
At the moment, 'bodhi' waits for a repo
by invoking the 'koji wait-repo' cli tool
while 'fedpkg' does not wait at all.
In order to make it easier for such tools to wait for a repo,
the wait implementation from 'koji wait-repo'
is moved to koji.utils namespace
where it is available for use through Python import.

Tests for the new function watchBuilds are still missing.
I intend to add them,
but since this my first contribution to Koji,
I would like to get a round of review first,
so my approach is validated
and I will not end up spending time in
writing tests for a feature that will not be merged.

buildLabel does this (with option to not/show epoch) Also note that epoch is integer, not string.

This is not the right library - watch_builds is CLI thing, so it should be in the CLI lib. Moving to koji_cli/lib.py is ok (it is also importable)

tracking issue #2981

buildLabel does this (with option to not/show epoch) Also note that epoch is integer, not string.

Nice, I was looking for existing implementation,
for some reason I did not spot buildLabel.
I will use that instead.

Now that I already wrote some unit tests,
and buildLabel apparently did not have any,
I will move the new tests to test buildLabel.

rebased onto c940e6b1d600ea4f40034cb6d8db4ce44cf335fc

Since the stated goal here is to make watch_build available to external tool implementations like bodhi, etc., would it make more sense to have quiet=True as the default, so that callers won't be surprised by status messages on the terminal unless they explicitly set quiet=True when calling watch_build()?

Having the quiet argument control the text content of the exception raised is... very weird. I would think that the exception should always be raised with all appropriate detail; the caller can determine whether or not to output that content based on their quiet status. (Even better would be to have more precise exceptions defined, where this could be e.g. a koji.TimeoutError derived from koji.GenericError. That way the caller can handle the different failure conditions differently.)

(IOW, regarding my previous comment, it would be better to always include the explanatory text in the exception, and change the call here to be something like...)

try:
    watch_builds(...)
except koji.GenericError as e:
    error(str(e) if not suboptions.quiet else "")

I've added some changes in #3406

Pull-Request has been closed by tkopecek

Metadata