From: Michael Tremer Date: Tue, 10 Oct 2017 12:41:15 +0000 (+0100) Subject: arches: Allow iterating over all architectures X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e454de15ed4cc609ff17dd843893402e8af2abc;p=pbs.git arches: Allow iterating over all architectures Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/arches.py b/src/buildservice/arches.py index cf648232..f8d2849e 100644 --- a/src/buildservice/arches.py +++ b/src/buildservice/arches.py @@ -22,6 +22,12 @@ def priority(arch): return 99 class Arches(base.Object): + def __iter__(self): + res = self.db.query("SELECT name FROM arches \ + WHERE NOT name = ANY(%s)", ("noarch", "src")) + + return sorted((a.name for a in res), key=priority) + def get_all(self, really=False): query = "SELECT * FROM arches" diff --git a/src/manager/builds.py b/src/manager/builds.py index c6ecd811..a1a06043 100644 --- a/src/manager/builds.py +++ b/src/manager/builds.py @@ -108,17 +108,11 @@ class CreateTestBuildsEvent(base.Event): def run(self): max_queue_length = self.pakfire.settings.get_int("test_queue_limit", 10) - # Get a list with all feasible architectures. - arches = self.pakfire.arches.get_all() - noarch = self.pakfire.arches.get_by_name("noarch") - if noarch: - arches.append(noarch) - - for arch in arches: + for arch in self.backend.arches: # Skip adding new jobs if there are more too many jobs in the queue. - limit = max_queue_length - self.backend.jobqueue.get_length_for_arch(arch.name) + limit = max_queue_length - self.backend.jobqueue.get_length_for_arch(arch) if limit <= 0: - logging.debug("Already too many jobs in queue of %s to create tests." % arch.name) + logging.debug("Already too many jobs in queue of %s to create tests." % arch) continue # Get a list of builds, with potentially need a test build.