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

Matthieu Patou mat at samba.org
Thu Nov 11 12:28:51 MST 2010


The branch, master has been updated
       via  6e90a43 use the cached version of the build farm for the web interface
       via  95c6516 Introduce a cached variant of the build farm, correct cached build to handle correctly CachedUploadBuild class
       via  9d55ade Do not use cache for lcov in the non cached variant of the buildfarm class
      from  e7f5f8b Move lcov cache onto BuildFarm, simplify get_build.

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


- Log -----------------------------------------------------------------
commit 6e90a43f98d85a0692bbade545ee85ae2ad321c1
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Nov 11 22:17:52 2010 +0300

    use the cached version of the build farm for the web interface

commit 95c65166b107b7366611750c020b190018393438
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Nov 11 22:16:06 2010 +0300

    Introduce a cached variant of the build farm, correct cached build to handle correctly CachedUploadBuild class

commit 9d55adeb51ca17348e42a22ca8145e7c85afada8
Author: Matthieu Patou <mat at matws.net>
Date:   Thu Nov 11 22:15:09 2010 +0300

    Do not use cache for lcov in the non cached variant of the buildfarm class

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

Summary of changes:
 buildfarm/__init__.py |   78 ++++++++++++++++++++++++++++++++++++++----------
 buildfarm/data.py     |   10 +++++-
 web/build.py          |    4 +-
 3 files changed, 71 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/__init__.py b/buildfarm/__init__.py
index 85690e3..bf6b0b0 100644
--- a/buildfarm/__init__.py
+++ b/buildfarm/__init__.py
@@ -100,34 +100,18 @@ class BuildFarm(object):
     def lcov_status(self, tree):
         """get status of build"""
         from buildfarm import data, util
-        cachefile = os.path.join(self.cachedir, "lcov.%s.%s.status" % (
-            self.LCOVHOST, tree))
         file = os.path.join(self.lcovdir, self.LCOVHOST, tree, "index.html")
         try:
-            st1 = os.stat(file)
+            lcov_html = util.FileLoad(file)
         except OSError:
             # File does not exist
             raise data.NoSuchBuildError(tree, self.LCOVHOST, "lcov")
-        try:
-            st2 = os.stat(cachefile)
-        except OSError:
-            # file does not exist
-            st2 = None
 
-        if st2 and st1.st_ctime <= st2.st_mtime:
-            ret = util.FileLoad(cachefile)
-            if ret == "":
-                return None
-            return ret
-
-        lcov_html = util.FileLoad(file)
         perc = lcov_extract_percentage(lcov_html)
         if perc is None:
             ret = ""
         else:
             ret = perc
-        if self.readonly:
-            util.FileSave(cachefile, ret)
         return perc
 
     def get_build(self, tree, host, compiler, rev=None):
@@ -148,3 +132,63 @@ class BuildFarm(object):
                         yield self.upload_builds.get_build(host, tree, compiler)
                     except data.NoSuchBuildError:
                         continue
+
+
+class CachingBuildFarm(BuildFarm):
+
+    def __init__(self, path=None, cachedirname=None):
+        self.cachedir = None
+        super(CachingBuildFarm, self).__init__(path)
+
+        if cachedirname:
+            self.cachedir = os.path.join(self.path, cachedirname)
+        else:
+            self.cachedir = os.path.join(self.path, "toto")
+        self.builds = self._open_build_results()
+        self.upload_builds = self._open_upload_build_results()
+
+    def _open_build_results(self):
+        from buildfarm import data
+        if not self.cachedir:
+            return
+        return data.CachingBuildResultStore(os.path.join(self.path, "data", "oldrevs"),
+                self.cachedir)
+
+    def _open_upload_build_results(self):
+        from buildfarm import data
+        if not self.cachedir:
+            return
+        return data.CachingUploadBuildResultStore(os.path.join(self.path, "data", "upload"),
+                self.cachedir)
+
+    def lcov_status(self, tree):
+        """get status of build"""
+        from buildfarm import data, util
+        cachefile = self.builds.get_lcov_cached_status(self.LCOVHOST, tree)
+        file = os.path.join(self.lcovdir, self.LCOVHOST, tree, "index.html")
+        try:
+            st1 = os.stat(file)
+        except OSError:
+            # File does not exist
+            raise data.NoSuchBuildError(tree, self.LCOVHOST, "lcov")
+        try:
+            st2 = os.stat(cachefile)
+        except OSError:
+            # file does not exist
+            st2 = None
+
+        if st2 and st1.st_ctime <= st2.st_mtime:
+            ret = util.FileLoad(cachefile)
+            if ret == "":
+                return None
+            return ret
+
+        lcov_html = util.FileLoad(file)
+        perc = lcov_extract_percentage(lcov_html)
+        if perc is None:
+            ret = ""
+        else:
+            ret = perc
+        if not self.readonly:
+            util.FileSave(cachefile, ret)
+        return perc
diff --git a/buildfarm/data.py b/buildfarm/data.py
index 9f7708c..0e09b13 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -270,7 +270,10 @@ class CachingBuild(Build):
     to calculate."""
 
     def revision_details(self):
-        cachef = self._store.cache_fname(self.tree, self.host, self.compiler, self.rev)
+        if self.rev:
+            cachef = self._store.cache_fname(self.tree, self.host, self.compiler, self.rev)
+        else:
+            cachef = self._store.cache_fname(self.tree, self.host, self.compiler)
         st1 = os.stat("%s.log" % self.basename)
 
         try:
@@ -316,7 +319,10 @@ class CachingBuild(Build):
         return ret
 
     def status(self):
-        cachefile = self._store.cache_fname(self.tree, self.host, self.compiler, self.rev)+".status"
+        if self.rev:
+            cachefile = self._store.cache_fname(self.tree, self.host, self.compiler, self.rev)+".status"
+        else:
+            cachefile = self._store.cache_fname(self.tree, self.host, self.compiler)+".status"
 
         st1 = os.stat("%s.log" % self.basename)
 
diff --git a/web/build.py b/web/build.py
index 6d06c3d..977f16e 100755
--- a/web/build.py
+++ b/web/build.py
@@ -30,7 +30,7 @@ import sys
 sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
 
 from buildfarm import (
-    BuildFarm,
+    CachingBuildFarm,
     data,
     history,
     util,
@@ -45,7 +45,7 @@ standalone = 0
 webdir = os.path.dirname(__file__)
 basedir = os.path.abspath(os.path.join(webdir, ".."))
 
-buildfarm = BuildFarm()
+buildfarm = CachingBuildFarm()
 
 db = data.BuildResultStore(basedir)
 #history = history.History(db)


-- 
build.samba.org


More information about the samba-cvs mailing list