[cig-commits] r5909 - in cs/buildbot/trunk/buildbot: . status
leif at geodynamics.org
leif at geodynamics.org
Fri Jan 26 10:50:09 PST 2007
Author: leif
Date: 2007-01-26 10:50:09 -0800 (Fri, 26 Jan 2007)
New Revision: 5909
Added:
cs/buildbot/trunk/buildbot/projects.py
Modified:
cs/buildbot/trunk/buildbot/categories.py
cs/buildbot/trunk/buildbot/interfaces.py
cs/buildbot/trunk/buildbot/master.py
cs/buildbot/trunk/buildbot/status/builder.py
cs/buildbot/trunk/buildbot/status/html.py
Log:
Began to formalize the concept of a Project. I'm not sure that I've
done the config stuff (c['projects']) right... BuildBot has a lot of
confusing logic here, the sole purpose of which is to make 'reconfig'
(SIGHUP) work smoothly.
Modified: cs/buildbot/trunk/buildbot/categories.py
===================================================================
--- cs/buildbot/trunk/buildbot/categories.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/categories.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -1,4 +1,7 @@
+from buildbot.projects import Project
+
+
class Category(object):
def __init__(self, **kwds):
@@ -7,8 +10,19 @@
class CategorySet(object):
- def __init__(self, args):
+ def __init__(self, args, status=None):
self.args = args
+ if status:
+ projects = status.getProjects()
+ projectNames = self.args.get('project')
+ if projectNames:
+ l = []
+ for p in projectNames:
+ if isinstance(p, basestring):
+ p = projects[p]
+ l.append(p)
+ self.args['project'] = l
+ return
def __contains__(self, item):
if item is None:
@@ -23,5 +37,8 @@
def subset(self, anotherSet):
ret = CategorySet(self.args.copy())
- ret.args.update(anotherSet)
+ ret.args.update(anotherSet.args)
return ret
+
+ def getAttribute(self, kw):
+ return self.args.get(kw)
Modified: cs/buildbot/trunk/buildbot/interfaces.py
===================================================================
--- cs/buildbot/trunk/buildbot/interfaces.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/interfaces.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -90,11 +90,6 @@
"""I am an object, obtainable from the buildmaster, which can provide
status information."""
- def getProjectName():
- """Return the name of the project that this Buildbot is working
- for."""
- def getProjectURL():
- """Return the URL of this Buildbot's project."""
def getBuildbotURL():
"""Return the URL of the top-most Buildbot status page, or None if
this Buildbot does not provide a web status page."""
Modified: cs/buildbot/trunk/buildbot/master.py
===================================================================
--- cs/buildbot/trunk/buildbot/master.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/master.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -496,8 +496,6 @@
persistenceVersion = 3
manhole = None
debugPassword = None
- projectName = "(unspecified)"
- projectURL = None
buildbotURL = None
change_svc = None
@@ -533,6 +531,7 @@
self.statusTargets = []
self.bots = []
+ self.projects = {}
# this ChangeMaster is a dummy, only used by tests. In the real
# buildmaster, where the BuildMaster instance is activated
# (startService is called) by twistd, this attribute is overwritten.
@@ -653,7 +652,7 @@
known_keys = "bots sources schedulers builders slavePortnum " + \
"debugPassword manhole " + \
- "status projectName projectURL buildbotURL"
+ "status projects buildbotURL"
known_keys = known_keys.split()
for k in config.keys():
if k not in known_keys:
@@ -666,13 +665,12 @@
schedulers = config['schedulers']
builders = config['builders']
slavePortnum = config['slavePortnum']
+ projects = config['projects']
# optional
debugPassword = config.get('debugPassword')
manhole = config.get('manhole')
status = config.get('status', [])
- projectName = config.get('projectName')
- projectURL = config.get('projectURL')
buildbotURL = config.get('buildbotURL')
except KeyError, e:
@@ -774,9 +772,9 @@
d = defer.succeed(None)
- self.projectName = projectName
- self.projectURL = projectURL
self.buildbotURL = buildbotURL
+ for p in projects:
+ self.projects[p.name] = p
# self.bots: Disconnect any that were attached and removed from the
# list. Update self.checker with the new list of passwords,
@@ -880,7 +878,6 @@
#if interfaces.IScheduler.providedBy(child)]
if interfaces.IScheduler(child, None)]
-
def loadConfig_Schedulers(self, newschedulers):
oldschedulers = self.allSchedulers()
removed = [s for s in oldschedulers if s not in newschedulers]
Added: cs/buildbot/trunk/buildbot/projects.py
===================================================================
--- cs/buildbot/trunk/buildbot/projects.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/projects.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -0,0 +1,12 @@
+
+from buildbot import util
+
+
+class Project(util.ComparableMixin):
+
+ compare_attrs = ['name', 'url', 'owners']
+
+ def __init__(self, name, url, owners):
+ self.name = name
+ self.url = url
+ self.owners = owners
Modified: cs/buildbot/trunk/buildbot/status/builder.py
===================================================================
--- cs/buildbot/trunk/buildbot/status/builder.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/status/builder.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -1780,10 +1780,6 @@
# methods called by our clients
- def getProjectName(self):
- return self.botmaster.parent.projectName
- def getProjectURL(self):
- return self.botmaster.parent.projectURL
def getBuildbotURL(self):
return self.botmaster.parent.buildbotURL
@@ -1850,6 +1846,9 @@
def getSchedulers(self):
return self.botmaster.parent.allSchedulers()
+ def getProjects(self):
+ return self.botmaster.parent.projects
+
def getBuilderNames(self, categories=None):
if categories == None:
return self.botmaster.builderNames[:] # don't let them break it
Modified: cs/buildbot/trunk/buildbot/status/html.py
===================================================================
--- cs/buildbot/trunk/buildbot/status/html.py 2007-01-26 18:24:07 UTC (rev 5908)
+++ cs/buildbot/trunk/buildbot/status/html.py 2007-01-26 18:50:09 UTC (rev 5909)
@@ -324,7 +324,7 @@
def body(self, request):
b = self.build
buildbotURL = self.status.getBuildbotURL()
- projectName = self.status.getProjectName()
+ projectName = "BuildBot"
data = '<div class="title"><a href="%s">%s</a></div>\n'%(buildbotURL,
projectName)
# the color in the following line gives python-mode trouble
@@ -503,7 +503,7 @@
connected_slaves = [s for s in slaves if s.isConnected()]
buildbotURL = self.status.getBuildbotURL()
- projectName = self.status.getProjectName()
+ projectName = "BuildBot"
data = "<a href=\"%s\">%s</a>\n" % (buildbotURL, projectName)
data += make_row("Builder:", html.escape(b.getName()))
b1 = b.getBuild(-1)
@@ -1077,11 +1077,20 @@
self.status = status
self.changemaster = changemaster
self.categories = categories
- p = self.status.getProjectName()
- if p:
- self.title = "BuildBot: %s" % p
self.css = css
+ project = self.getProject(self.categories)
+ if project:
+ self.title = "BuildBot: %s" % project.name
+ return
+ def getProject(self, categories):
+ """If a Project is uniquely determined, return it."""
+ if categories:
+ projects = categories.getAttribute('project')
+ if projects and len(projects) == 1:
+ return projects[0]
+ return None
+
def body(self, request):
"This method builds the main waterfall display."
@@ -1089,16 +1098,14 @@
data = ''
- projectName = self.status.getProjectName()
- projectURL = self.status.getProjectURL()
-
phase = request.args.get("phase",["2"])
phase = int(phase[0])
+ requestCategories = CategorySet(request.args, self.status)
if self.categories is None:
- categories = CategorySet(request.args)
+ categories = requestCategories
else:
- categories = self.categories.subset(request.args)
+ categories = self.categories.subset(requestCategories)
builderNames = self.status.getBuilderNames(categories=categories)
builders = map(lambda name: self.status.getBuilder(name),
builderNames)
@@ -1113,10 +1120,11 @@
# start the table: top-header material
data += '<table border="0" cellspacing="0">\n'
- if projectName and projectURL:
+ project = self.getProject(categories)
+ if project:
# TODO: this is going to look really ugly
topleft = "<a href=\"%s\">%s</a><br />last build" % \
- (projectURL, projectName)
+ (project.url, project.name)
else:
topleft = "last build"
data += ' <tr class="LastBuild">\n'
@@ -1160,13 +1168,13 @@
data += "<a href=\"http://buildbot.sourceforge.net/\">Buildbot</a>"
data += "-%s " % version
- if projectName:
+ if project:
data += "working for the "
- if projectURL:
- data += "<a href=\"%s\">%s</a> project." % (projectURL,
- projectName)
+ if project.url:
+ data += "<a href=\"%s\">%s</a> project." % (project.url,
+ project.name)
else:
- data += "%s project." % projectName
+ data += "%s project." % project.name
data += "<br />\n"
# TODO: push this to the right edge, if possible
data += ("Page built: " +
More information about the cig-commits
mailing list