[SCM] build.samba.org - branch master updated

Jelmer Vernooij jelmer at samba.org
Wed Nov 10 02:04:57 MST 2010


The branch, master has been updated
       via  ee296a4 Simplify some code.
       via  1459e8f Simplify new build iteration.
       via  5bd8f3b More work on import and analyse.
      from  7851c49 Split up further.

http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ee296a4ceeb7338d3f5d572f2f591ba4ab3a0f07
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 10 10:05:34 2010 +0100

    Simplify some code.

commit 1459e8f65ea41886db18c6387e7b4968f3a2723b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 10 09:44:57 2010 +0100

    Simplify new build iteration.

commit 5bd8f3b6c81edcc765b0c57c460a94c7bed6ebde
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 10 09:38:26 2010 +0100

    More work on import and analyse.

-----------------------------------------------------------------------

Summary of changes:
 buildfarm/__init__.py        |   19 ++++++++++++++++
 buildfarm/data.py            |   14 ++---------
 buildfarm/tests/test_util.py |    8 -------
 buildfarm/util.py            |    5 ----
 import-and-analyse.py        |   48 ++++++++++++++----------------------------
 5 files changed, 38 insertions(+), 56 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/__init__.py b/buildfarm/__init__.py
index 30c6005..b12fb7b 100644
--- a/buildfarm/__init__.py
+++ b/buildfarm/__init__.py
@@ -19,6 +19,7 @@
 
 import ConfigParser
 import os
+import re
 
 
 class Tree(object):
@@ -70,6 +71,7 @@ class BuildFarm(object):
             raise Exception("web directory %s does not exist" % self.webdir)
         self.trees = read_trees_from_conf(os.path.join(self.webdir, "trees.conf"))
         self.builds = self._open_build_results()
+        self.upload_builds = self._open_upload_builds_results()
         self.hostdb = self._open_hostdb()
         self.compilers = self._load_compilers()
         self.lcovdir = os.path.join(self.path, "lcov/data")
@@ -81,6 +83,10 @@ class BuildFarm(object):
         from buildfarm import data
         return data.BuildResultStore(os.path.join(self.path, "data", "oldrevs"))
 
+    def _open_upload_build_results(self):
+        from buildfarm import data
+        return data.UploadBuildResultStore(os.path.join(self.path, "data", "upload"))
+
     def _open_hostdb(self):
         from buildfarm import hostdb
         return hostdb.HostDatabase(
@@ -122,3 +128,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
diff --git a/buildfarm/data.py b/buildfarm/data.py
index 7ff8c92..7062431 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -226,12 +226,11 @@ class Build(object):
 
         :return: Tuple with revision id and timestamp (if available)
         """
-        file = self._store.build_fname(self.tree, self.host, self.compiler, self.rev)
 
         revid = None
         commit_revid = None
         timestamp = None
-        f = open("%s.log" % file, 'r')
+        f = self.read_log()
         try:
             for l in f.readlines():
                 if l.startswith("BUILD COMMIT REVISION: "):
@@ -262,15 +261,8 @@ class Build(object):
 
     def err_count(self):
         """get status of build"""
-        file = self._store.build_fname(self.tree, self.host, self.compiler, self.rev)
-
-        try:
-            err = util.FileLoad("%s.err" % file)
-        except OSError:
-            # File does not exist
-            return 0
-
-        return util.count_lines(err)
+        file = self.read_err()
+        return len(file.readlines())
 
 
 class CachingBuild(Build):
diff --git a/buildfarm/tests/test_util.py b/buildfarm/tests/test_util.py
index 3a1d5a4..79a311d 100755
--- a/buildfarm/tests/test_util.py
+++ b/buildfarm/tests/test_util.py
@@ -22,14 +22,6 @@ import unittest
 
 from buildfarm import util
 
-class CountLinesTests(unittest.TestCase):
-
-    def test_simple(self):
-        self.assertEquals(2, util.count_lines("foo\nbar"))
-        self.assertEquals(1, util.count_lines("bar"))
-        self.assertEquals(1, util.count_lines(""))
-
-
 class ChangeExtensionTests(unittest.TestCase):
 
     def test_simple(self):
diff --git a/buildfarm/util.py b/buildfarm/util.py
index 83346c1..60b263e 100644
--- a/buildfarm/util.py
+++ b/buildfarm/util.py
@@ -77,11 +77,6 @@ def ChangeExtension(fname, ext):
         return "%s.%s" % (base, ext)
 
 
-def count_lines(s):
-    """count the number of lines in a buffer"""
-    return len(s.split("\n"))
-
-
 def dhm_time(sec):
     """display a time as days, hours, minutes"""
     days = int(sec / (60*60*24));
diff --git a/import-and-analyse.py b/import-and-analyse.py
index 68ad09a..d45be19 100644
--- a/import-and-analyse.py
+++ b/import-and-analyse.py
@@ -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,36 +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:
-            retry = 0
-            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 = db.get_build(host, tree, compiler)
-            except data.NoSuchBuildError:
-                continue
-
-            if opts.verbose >= 2:
-                print "Processing %s..." % build
-
-            db.upload_build(build)
-
-            (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())
+for build in buildfarm.get_new_builds():
+    if opts.verbose >= 2:
+        print "Processing %s..." % build
+
+    db.upload_build(build)
+
+    (rev, commit_rev, rev_timestamp) = db.revision_details()
+
+    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()


-- 
build.samba.org


More information about the samba-cvs mailing list