]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
arches: Allow iterating over all architectures
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Oct 2017 12:41:15 +0000 (13:41 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Oct 2017 12:41:15 +0000 (13:41 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/arches.py
src/manager/builds.py

index cf6482328486cad650d8ded00e101cf3395d5407..f8d2849e3eaff28b18483facb1da06fdb7c3dd56 100644 (file)
@@ -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"
 
index c6ecd811b557cbed2dd0c92b25bbdaab1378dca9..a1a060431e38e19257164b340ecb0006d67b6879 100644 (file)
@@ -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.