(I miss a component for python-copr) Please, provide a simpler way how to find out whether a build was successful. Currently, I do: result = cl.create_new_build(project, pkgs=pkgs) success = all(build.handle.get_build_details().status != 'failed' for build in result.builds_list) BTW, is this correct? I mean, do I use API? I think that this is unnecessarily chatty since it is probably were common task. I am thinking about something like "result.success()".
Valentin, please make sure this will be in APIv2.
s/were/very BTW, I forgot to add the loop waiting for the build to be finished: result = cl.create_new_build(project, pkgs=pkgs) while True: remaining = [bw.build_id for bw in result.builds_list if bw.handle.get_build_details().status not in ["skipped", "failed", "succeeded"]] if not remaining: break time.sleep(1) success = all(build.handle.get_build_details().status != 'failed' for build in result.builds_list) The loop is also going to repeat in a lot of the COPR clients, I guess. Maybe the new function can be similar to Python's "Popen.wait(timeout=None)". It could wait for the build to terminate and return the status. Or something like the "Popen.poll()" (this is the original request). Or even we could have something like "Popen.call()" in addition to "cl.create_new_build". What do you think about these proposals? Which variant are you going to choose? I can file an RFE for each of these proposals since all of them makes sense to me and I can imagine that they can live together.
>>> I think that this is unnecessarily chatty since it is probably were common task. Well it is, but we now talking about business logic, and API should only provide an interface to the service. If we implement this task some user may want to show progress, so we would be forced to add some hook function. >>> I am thinking about something like "result.success()" Seems reasonable, accepted. >>> The loop is also going to repeat in a lot of the COPR clients, I guess. Maybe the new function can be similar to Python's "Popen.wait(timeout=None)". It could wait for the build to terminate and return the status. Or something like the "Popen.poll()" (this is the original request). Or even we could have something like "Popen.call()" in addition to "cl.create_new_build". Well, python-copr uses HTTP requests to communicate with the Copr service, so any .wait() method would be translated into the periodical calls to the service. I would think about addition of a helper function `wait_builds(build_id_list, check_period=60)` which would block until all given builds are finished.
We apologize, that this took years, but it is finally implemented. Meanwhile, both APIv1 (aka Legacy API) and APIv2 (aka REST-like API) are deprecated, so this was implemented in new APIv3. See this example code from copr.v3 import Client client = Client.create_from_config_file() build1 = client.build_proxy.create_from_file(...) build2 = client.build_proxy.create_from_scm(...) finished = wait([build1, build2]) print("Builds have finished {}sucessfully".format( "" if succeeded(finished) else "un"))
This BZ was fixed during the latest Copr release. Feel free to reopen, if you encounter any difficulties with the provided solution.