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

Jelmer Vernooij jelmer at samba.org
Sun Nov 21 06:09:28 MST 2010


The branch, master has been updated
       via  e05015e More work on builds.
       via  87300e1 Add command-line utility for iterating builds.
       via  6916e36 Simplify code a bit.
      from  55d7006 Fix standalone run.

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


- Log -----------------------------------------------------------------
commit e05015ec261c9a8061fa3c14dfd57d1d22094541
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Nov 21 13:59:36 2010 +0100

    More work on builds.

commit 87300e14429417a42e03c9209c601ad499805664
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Nov 21 13:58:32 2010 +0100

    Add command-line utility for iterating builds.

commit 6916e36a6d10384d6451e67e4693204648fec1e6
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Nov 21 04:41:42 2010 +0100

    Simplify code a bit.

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

Summary of changes:
 buildfarm/data.py         |   10 ++++++++--
 buildfarm/sqldb.py        |   21 +++++++++++++++++----
 buildfarm/web/__init__.py |   18 +++++++++++-------
 builds.py                 |   40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 13 deletions(-)
 create mode 100755 builds.py


Changeset truncated at 500 lines:

diff --git a/buildfarm/data.py b/buildfarm/data.py
index ceaabb7..a551b81 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -49,6 +49,10 @@ class MissingRevisionInfo(Exception):
         self.build = build
 
 
+class LogFileMissing(Exception):
+    """Log file missing."""
+
+
 class BuildStatus(object):
 
     def __init__(self, stages=None, other_failures=None):
@@ -248,12 +252,14 @@ class Build(object):
     @property
     def age(self):
         """get the age of build"""
-        st = os.stat("%s.log" % self.basename)
         return time.time() - self.upload_time
 
     def read_log(self):
         """read full log file"""
-        return open(self.basename+".log", "r")
+        try:
+            return open(self.basename+".log", "r")
+        except IOError:
+            raise LogFileMissing()
 
     def read_err(self):
         """read full err file"""
diff --git a/buildfarm/sqldb.py b/buildfarm/sqldb.py
index 2c3c932..0e56137 100644
--- a/buildfarm/sqldb.py
+++ b/buildfarm/sqldb.py
@@ -51,12 +51,14 @@ class StormBuild(Build):
     tree = RawStr()
     revision = RawStr()
     host = RawStr()
-    host_id = Int()
     compiler = RawStr()
     checksum = RawStr()
     upload_time = Int(name="age")
+    commit = Unicode()
     status_str = RawStr(name="status")
+    commit_revision = RawStr()
     basename = RawStr()
+    host_id = Int()
 
     def status(self):
         return BuildStatus.__deserialize__(self.status_str)
@@ -218,6 +220,17 @@ class StormCachingBuildResultStore(BuildResultStore):
             StormBuild.host == host,
             StormBuild.compiler == compiler).order_by(Desc(StormBuild.upload_time))
 
+    def get_build(self, tree, host, compiler, revision):
+        result = self.store.find(StormBuild,
+            StormBuild.tree == tree,
+            StormBuild.host == host,
+            StormBuild.compiler == compiler,
+            StormBuild.revision == revision)
+        ret = result.one()
+        if ret is None:
+            raise NoSuchBuildError(tree, host, compiler, revision)
+        return ret
+
 
 class StormCachingBuildFarm(BuildFarm):
 
@@ -244,11 +257,11 @@ class StormCachingBuildFarm(BuildFarm):
 
     def get_host_builds(self, host):
         return self._get_store().find(StormBuild,
-            StormBuild.host == host).group_by(StormBuild.compiler, StormBuild.tree)
+            StormBuild.host==host).group_by(StormBuild.compiler, StormBuild.tree)
 
     def get_tree_builds(self, tree):
-        return self._get_store().find(StormBuild,
-            StormBuild.tree == tree).order_by(Desc(StormBuild.upload_time))
+        result = self._get_store().find(StormBuild, StormBuild.tree==tree)
+        return result.order_by(Desc(StormBuild.upload_time))
 
     def get_last_builds(self):
         return self._get_store().find(StormBuild).group_by(
diff --git a/buildfarm/web/__init__.py b/buildfarm/web/__init__.py
index b7b5917..d9fd3f1 100755
--- a/buildfarm/web/__init__.py
+++ b/buildfarm/web/__init__.py
@@ -445,7 +445,7 @@ class ViewBuildPage(BuildFarmPage):
         """show the available old revisions, if any"""
         old_rev_builds  = self.buildfarm.builds.get_old_revs(tree, host, compiler)
 
-        if len(old_rev_builds) == 0:
+        if not old_rev_builds:
             return
 
         yield "<h2>Older builds:</h2>\n"
@@ -482,11 +482,14 @@ class ViewBuildPage(BuildFarmPage):
         if rev:
             assert re.match("^[0-9a-fA-F]*$", rev)
 
-        f = build.read_log()
         try:
-            log = f.read()
-        finally:
-            f.close()
+            f = build.read_log()
+            try:
+                log = f.read()
+            finally:
+                f.close()
+        except data.LogFileMissing:
+            log = "Missing log file."
         f = build.read_err()
         try:
             err = f.read()
@@ -592,8 +595,9 @@ class ViewRecentBuildsPage(BuildFarmPage):
             "status": lambda a, b: cmp(a[6], b[6]),
             }
 
-        assert tree in self.buildfarm.trees, "not a build tree"
-        assert sort_by in cmp_funcs, "not a valid sort"
+        if sort_by not in cmp_funcs:
+            yield "not a valid sort mechanism: %r" % sort_by
+            return
 
         for build in self.buildfarm.get_tree_builds(tree):
             try:
diff --git a/builds.py b/builds.py
new file mode 100755
index 0000000..d08c339
--- /dev/null
+++ b/builds.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# Samba.org buildfarm
+# Copyright (C) 2010 Jelmer Vernooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from buildfarm.sqldb import StormCachingBuildFarm
+import optparse
+import sys
+
+parser = optparse.OptionParser("")
+parser.add_option("--tree", help="Print builds for a specific tree.", type=str)
+parser.add_option("--last", help="Print last builds.", action="store_true")
+
+(opts, args) = parser.parse_args()
+
+buildfarm = StormCachingBuildFarm()
+
+if opts.tree:
+    builds = buildfarm.get_tree_builds(opts.tree)
+elif opts.last:
+    builds = buildfarm.get_last_builds()
+else:
+    parser.print_usage()
+    sys.exit(1)
+
+for build in builds:
+    print build


-- 
build.samba.org


More information about the samba-cvs mailing list