[jhbuild] JhBuildMaster.loadConfig(): sync code with upstream (buildbot-0.7.12)



commit 43801d70412e7916a3a232df80021f7de7c106e2
Author: Sascha Silbe <sascha-pgp silbe org>
Date:   Thu Mar 25 14:45:32 2010 +0000

    JhBuildMaster.loadConfig(): sync code with upstream (buildbot-0.7.12)

 jhbuild/commands/bot.py |  129 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 103 insertions(+), 26 deletions(-)
---
diff --git a/jhbuild/commands/bot.py b/jhbuild/commands/bot.py
index 4ab28c5..e33206a 100644
--- a/jhbuild/commands/bot.py
+++ b/jhbuild/commands/bot.py
@@ -365,10 +365,13 @@ class cmd_bot(Command):
 
                 known_keys = ("bots", "slaves",
                               "sources", "change_source",
-                              "schedulers", "builders",
-                              "slavePortnum", "debugPassword", "manhole",
-                              "status", "projectName", "projectURL", "buildbotURL",
-                              "properties"
+                              "schedulers", "builders", "mergeRequests",
+                              "slavePortnum", "debugPassword", "logCompressionLimit",
+                              "manhole", "status", "projectName", "projectURL",
+                              "buildbotURL", "properties", "prioritizeBuilders",
+                              "eventHorizon", "buildCacheSize", "logHorizon", "buildHorizon",
+                              "changeHorizon", "logMaxSize", "logMaxTailSize",
+                              "logCompressionMethod",
                               )
                 for k in config.keys():
                     if k not in known_keys:
@@ -471,13 +474,6 @@ class cmd_bot(Command):
                     # required
                     schedulers = config['schedulers']
                     builders = config['builders']
-                    for k in builders:
-                        if k['name'].startswith("_"):
-                            errmsg = ("builder names must not start with an "
-                                      "underscore: " + k['name'])
-                            log.err(errmsg)
-                            raise ValueError(errmsg)
-
                     slavePortnum = config['slavePortnum']
                     #slaves = config['slaves']
                     #change_source = config['change_source']
@@ -490,6 +486,34 @@ class cmd_bot(Command):
                     projectURL = config.get('projectURL')
                     buildbotURL = config.get('buildbotURL')
                     properties = config.get('properties', {})
+                    buildCacheSize = config.get('buildCacheSize', None)
+                    eventHorizon = config.get('eventHorizon', None)
+                    logHorizon = config.get('logHorizon', None)
+                    buildHorizon = config.get('buildHorizon', None)
+                    logCompressionLimit = config.get('logCompressionLimit', 4*1024)
+                    if logCompressionLimit is not None and not \
+                            isinstance(logCompressionLimit, int):
+                        raise ValueError("logCompressionLimit needs to be bool or int")
+                    logCompressionMethod = config.get('logCompressionMethod', "bz2")
+                    if logCompressionMethod not in ('bz2', 'gz'):
+                        raise ValueError("logCompressionMethod needs to be 'bz2', or 'gz'")
+                    logMaxSize = config.get('logMaxSize')
+                    if logMaxSize is not None and not \
+                            isinstance(logMaxSize, int):
+                        raise ValueError("logMaxSize needs to be None or int")
+                    logMaxTailSize = config.get('logMaxTailSize')
+                    if logMaxTailSize is not None and not \
+                            isinstance(logMaxTailSize, int):
+                        raise ValueError("logMaxTailSize needs to be None or int")
+                    mergeRequests = config.get('mergeRequests')
+                    if mergeRequests is not None and not callable(mergeRequests):
+                        raise ValueError("mergeRequests must be a callable")
+                    prioritizeBuilders = config.get('prioritizeBuilders')
+                    if prioritizeBuilders is not None and not callable(prioritizeBuilders):
+                        raise ValueError("prioritizeBuilders must be callable")
+                    changeHorizon = config.get("changeHorizon")
+                    if changeHorizon is not None and not isinstance(changeHorizon, int):
+                        raise ValueError("changeHorizon needs to be an int")
 
                 except KeyError, e:
                     log.msg("config dictionary is missing a required parameter")
@@ -516,6 +540,9 @@ class cmd_bot(Command):
                 #if "sources" in config:
                 #    raise KeyError("c['sources'] is no longer accepted")
 
+                if changeHorizon is not None:
+                    self.change_svc.changeHorizon = changeHorizon
+
                 change_source = config.get('change_source', [])
                 if isinstance(change_source, (list, tuple)):
                     change_sources = change_source
@@ -531,9 +558,10 @@ class cmd_bot(Command):
 
                 # do some validation first
                 for s in slaves:
-                    assert isinstance(s, JhBuildSlave)
+                    assert interfaces.IBuildSlave.providedBy(s)
                     if s.slavename in ("debug", "change", "status"):
-                        raise KeyError, "reserved name '%s' used for a bot" % s.slavename
+                        raise KeyError(
+                            "reserved name '%s' used for a bot" % s.slavename)
                 if config.has_key('interlocks'):
                     raise KeyError("c['interlocks'] is no longer accepted")
 
@@ -553,10 +581,19 @@ class cmd_bot(Command):
                 slavenames = [s.slavename for s in slaves]
                 buildernames = []
                 dirnames = []
+
+                # convert builders from objects to config dictionaries
+                builders_dicts = []
+                for b in builders:
+                    if isinstance(b, buildbot.config.BuilderConfig):
+                        builders_dicts.append(b.getConfigDict())
+                    elif type(b) is dict:
+                        builders_dicts.append(b)
+                    else:
+                        raise ValueError("builder %s is not a BuilderConfig object (or a dict)" % b)
+                builders = builders_dicts
+
                 for b in builders:
-                    if type(b) is tuple:
-                        raise ValueError("builder %s must be defined with a dict, "
-                                         "not a tuple" % b[0])
                     if b.has_key('slavename') and b['slavename'] not in slavenames:
                         raise ValueError("builder %s uses undefined slave %s" \
                                          % (b['name'], b['slavename']))
@@ -568,6 +605,19 @@ class cmd_bot(Command):
                         raise ValueError("duplicate builder name %s"
                                          % b['name'])
                     buildernames.append(b['name'])
+
+                    # sanity check name (BuilderConfig does this too)
+                    if b['name'].startswith("_"):
+                        errmsg = ("builder names must not start with an "
+                                  "underscore: " + b['name'])
+                        log.err(errmsg)
+                        raise ValueError(errmsg)
+
+                    # Fix the dictionnary with default values, in case this wasn't
+                    # specified with a BuilderConfig object (which sets the same defaults)
+                    b.setdefault('builddir', buildbot.util.safeTranslate(b['name']))
+                    b.setdefault('slavebuilddir', b['builddir'])
+
                     if b['builddir'] in dirnames:
                         raise ValueError("builder %s reuses builddir %s"
                                          % (b['name'], b['builddir']))
@@ -598,28 +648,32 @@ class cmd_bot(Command):
 
                 # assert that all locks used by the Builds and their Steps are
                 # uniquely named.
-                locks = {}
+                lock_dict = {}
                 for b in builders:
                     for l in b.get('locks', []):
-                        if locks.has_key(l.name):
-                            if locks[l.name] is not l:
+                        if isinstance(l, locks.LockAccess): # User specified access to the lock
+                            l = l.lockid
+                        if lock_dict.has_key(l.name):
+                            if lock_dict[l.name] is not l:
                                 raise ValueError("Two different locks (%s and %s) "
                                                  "share the name %s"
-                                                 % (l, locks[l.name], l.name))
+                                                 % (l, lock_dict[l.name], l.name))
                         else:
-                            locks[l.name] = l
+                            lock_dict[l.name] = l
                     # TODO: this will break with any BuildFactory that doesn't use a
                     # .steps list, but I think the verification step is more
                     # important.
                     for s in b['factory'].steps:
                         for l in s[1].get('locks', []):
-                            if locks.has_key(l.name):
-                                if locks[l.name] is not l:
+                            if isinstance(l, locks.LockAccess): # User specified access to the lock
+                                l = l.lockid
+                            if lock_dict.has_key(l.name):
+                                if lock_dict[l.name] is not l:
                                     raise ValueError("Two different locks (%s and %s)"
                                                      " share the name %s"
-                                                     % (l, locks[l.name], l.name))
+                                                     % (l, lock_dict[l.name], l.name))
                             else:
-                                locks[l.name] = l
+                                lock_dict[l.name] = l
 
                 if not isinstance(properties, dict):
                     raise ValueError("c['properties'] must be a dictionary")
@@ -638,10 +692,33 @@ class cmd_bot(Command):
                 self.projectName = projectName
                 self.projectURL = projectURL
                 self.buildbotURL = buildbotURL
-                
+
                 self.properties = Properties()
                 self.properties.update(properties, self.configFileName)
 
+                self.status.logCompressionLimit = logCompressionLimit
+                self.status.logCompressionMethod = logCompressionMethod
+                self.status.logMaxSize = logMaxSize
+                self.status.logMaxTailSize = logMaxTailSize
+                # Update any of our existing builders with the current log parameters.
+                # This is required so that the new value is picked up after a
+                # reconfig.
+                for builder in self.botmaster.builders.values():
+                    builder.builder_status.setLogCompressionLimit(logCompressionLimit)
+                    builder.builder_status.setLogCompressionMethod(logCompressionMethod)
+                    builder.builder_status.setLogMaxSize(logMaxSize)
+                    builder.builder_status.setLogMaxTailSize(logMaxTailSize)
+
+                if mergeRequests is not None:
+                    self.botmaster.mergeRequests = mergeRequests
+                if prioritizeBuilders is not None:
+                    self.botmaster.prioritizeBuilders = prioritizeBuilders
+
+                self.buildCacheSize = buildCacheSize
+                self.eventHorizon = eventHorizon
+                self.logHorizon = logHorizon
+                self.buildHorizon = buildHorizon
+
                 # self.slaves: Disconnect any that were attached and removed from the
                 # list. Update self.checker with the new list of passwords, including
                 # debug/change/status.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]