Helper Functions

The copr.v3 module provides several utility functions that make working with builds and other operations more convenient.

wait function

The wait function allows you to wait for builds to complete before continuing execution.

copr.v3.wait(waitable, interval=30, callback=None, timeout=0)[source]

Wait for a waitable thing to finish. At this point, it is possible to wait only for builds, but this function should be enhanced to wait for e.g. modules or images, etc in the future

Parameters:
  • waitable (Munch/list) – A Munch result or list of munches

  • interval (int) – How many seconds wait before requesting updated Munches from frontend

  • callback (callable) – Callable taking one argument (list of build Munches). It will be triggered before every sleep interval.

  • timeout (int) – Limit how many seconds should be waited before this function unsuccessfully ends

Returns:

list of build Munches

Example usage:

build1 = client.build_proxy.create_from_file(…) build2 = client.build_proxy.create_from_scm(…) wait([build1, build2])

Usage Example

from copr.v3 import Client, wait

# Create a client
client = Client.create_from_config_file()

# Submit builds
build1 = client.build_proxy.create_from_file("@user", "project", "/path/to/file.src.rpm")
build2 = client.build_proxy.create_from_url("@user", "project", "http://example.com/package.src.rpm")

# Wait for both builds to finish
finished_builds = wait([build1, build2])

# Check the results
for build in finished_builds:
    print(f"Build {build.id} finished with state: {build.state}")

With Callback

You can provide a callback function to monitor progress:

from copr.v3 import Client, wait

def progress_callback(builds):
    for build in builds:
        print(f"Build {build.id}: {build.state}")

client = Client.create_from_config_file()
build = client.build_proxy.create_from_file("@user", "project", "/path/to/file.src.rpm")

# Wait with progress updates every 30 seconds
wait(build, callback=progress_callback)