import ConfigParser
import os
+import re
class Tree(object):
if path is None:
path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
self.path = path
+ self.cachedir = os.path.join(self.path, "cache")
self.webdir = os.path.join(self.path, "web")
if not os.path.isdir(path):
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.upload_builds = self._open_upload_build_results()
self.hostdb = self._open_hostdb()
self.compilers = self._load_compilers()
self.lcovdir = os.path.join(self.path, "lcov/data")
def lcov_status(self, tree):
"""get status of build"""
from buildfarm import data, util
- cachefile = os.path.join(self.builds.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):
+ if rev:
+ return self.builds.get_build(tree, host, compiler, rev)
+ else:
+ return self.upload_builds.get_build(tree, host, compiler)
+
+ def get_new_builds(self):
+ from buildfarm import data
+ for host in self.hostdb.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