Simplify new build iteration.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 10 Nov 2010 08:44:57 +0000 (09:44 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 10 Nov 2010 08:44:57 +0000 (09:44 +0100)
buildfarm/__init__.py
import-and-analyse.py

index bde1a7fa9dc85dfb9de80be6c349daa90337396f..165fa78ed4b9d1ec315d28343eac900db94c42a4 100644 (file)
@@ -127,3 +127,16 @@ class BuildFarm(object):
         if self.readonly:
             util.FileSave(cachefile, ret)
         return perc
+
+    def get_new_builds(self):
+        from buildfarm import data
+        for host in self.hostsdb.hosts():
+            for tree in self.trees:
+                for compiler in self.compilers:
+                    # By building the log file name this way, using only the list of
+                    # hosts, trees and compilers as input, we ensure we
+                    # control the inputs
+                    try:
+                        yield self.upload_builds.get_build(host, tree, compiler)
+                    except data.NoSuchBuildError:
+                        continue
index 1e7968792d37cdc97a4b64d4122fdb5ea0105ed0..d45be190ad6b7cc940b3aa03a0952504229ba799 100644 (file)
@@ -38,8 +38,6 @@ buildfarm = BuildFarm()
 db = data.BuildResultStore(os.path.abspath(os.path.dirname(__file__)), True)
 hostsdb = buildfarm.hostdb
 
-hosts = hostsdb.hosts()
-
 smtp = smtplib.SMTP()
 smtp.connect()
 
@@ -146,35 +144,22 @@ The build may have been broken by one of the following commits:
     smtp.send(msg["From"], [msg["To"]], msg.as_string())
 
 
-for host in hosts:
-    for tree in buildfarm.trees:
-        for compiler in buildfarm.compilers:
-            if opts.verbose >= 2:
-                print "Looking for a log file for %s %s %s..." % (host, compiler, tree)
-
-            # By building the log file name this way, using only the list of
-            # hosts, trees and compilers as input, we ensure we
-            # control the inputs
-            try:
-                build = buildfarm.upload_builds.get_build(host, tree, compiler)
-            except data.NoSuchBuildError:
-                continue
+for build in buildfarm.get_new_builds():
+    if opts.verbose >= 2:
+        print "Processing %s..." % build
 
-            if opts.verbose >= 2:
-                print "Processing %s..." % build
+    db.upload_build(build)
 
-            db.upload_build(build)
+    (rev, commit_rev, rev_timestamp) = db.revision_details()
 
-            (rev, commit_rev, rev_timestamp) = db.revision_details()
-
-            try:
-                prev_rev = db.get_previous_revision(tree, host, compiler, rev)
-            except hostdb.NoSuchBuild:
-                # Can't send a nastygram until there are 2 builds..
-                continue
-            else:
-                prev_build = db.get_build(tree, host, compiler, prev_rev)
-                check_and_send_mails(tree, host, compiler, build.status(), prev_build.status())
+    try:
+        prev_rev = db.get_previous_revision(build.tree, build.host, build.compiler, rev)
+    except hostdb.NoSuchBuild:
+        # Can't send a nastygram until there are 2 builds..
+        continue
+    else:
+        prev_build = db.get_build(build.tree, build.host, build.compiler, prev_rev)
+        check_and_send_mails(build.tree, build.host, build.compiler, build.status(), prev_build.status())
 
 
 smtp.quit()