Package buildbot :: Module config
[frames] | no frames]

Source Code for Module buildbot.config

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16  from buildbot.util import safeTranslate 
 17   
 18   
19 -class MasterConfig(object):
20 """ 21 Namespace for master configuration values. An instance of this class is 22 available at C{master.config}. 23 24 @ivar changeHorizon: the current change horizon 25 @ivar validation: regexes for preventing invalid inputs 26 """ 27 28 changeHorizon = None
29
30 -class BuilderConfig:
31 """ 32 33 Used in config files to specify a builder - this can be subclassed by users 34 to add extra config args, set defaults, or whatever. It is converted to a 35 dictionary for consumption by the buildmaster at config time. 36 37 """ 38
39 - def __init__(self, 40 name=None, 41 slavename=None, 42 slavenames=None, 43 builddir=None, 44 slavebuilddir=None, 45 factory=None, 46 category=None, 47 nextSlave=None, 48 nextBuild=None, 49 locks=None, 50 env=None, 51 properties=None, 52 mergeRequests=None):
53 54 # name is required, and can't start with '_' 55 if not name or type(name) not in (str, unicode): 56 raise ValueError("builder's name is required") 57 if name[0] == '_': 58 raise ValueError("builder names must not start with an " 59 "underscore: " + name) 60 self.name = name 61 62 # factory is required 63 if factory is None: 64 raise ValueError("builder's factory is required") 65 self.factory = factory 66 67 # slavenames can be a single slave name or a list, and should also 68 # include slavename, if given 69 if type(slavenames) is str: 70 slavenames = [ slavenames ] 71 if slavenames: 72 if type(slavenames) is not list: 73 raise TypeError("slavenames must be a list or a string") 74 else: 75 slavenames = [] 76 if slavename: 77 if type(slavename) != str: 78 raise TypeError("slavename must be a string") 79 slavenames = slavenames + [ slavename ] 80 if not slavenames: 81 raise ValueError("at least one slavename is required") 82 self.slavenames = slavenames 83 84 # builddir defaults to name 85 if builddir is None: 86 builddir = safeTranslate(name) 87 self.builddir = builddir 88 89 # slavebuilddir defaults to builddir 90 if slavebuilddir is None: 91 slavebuilddir = builddir 92 self.slavebuilddir = slavebuilddir 93 94 # remainder are optional 95 assert category is None or isinstance(category, str) 96 self.category = category 97 self.nextSlave = nextSlave 98 self.nextBuild = nextBuild 99 self.locks = locks 100 self.env = env 101 self.properties = properties 102 self.mergeRequests = mergeRequests
103
104 - def getConfigDict(self):
105 rv = { 106 'name': self.name, 107 'slavenames': self.slavenames, 108 'factory': self.factory, 109 'builddir': self.builddir, 110 'slavebuilddir': self.slavebuilddir, 111 } 112 if self.category: 113 rv['category'] = self.category 114 if self.nextSlave: 115 rv['nextSlave'] = self.nextSlave 116 if self.nextBuild: 117 rv['nextBuild'] = self.nextBuild 118 if self.locks: 119 rv['locks'] = self.locks 120 if self.env: 121 rv['env'] = self.env 122 if self.properties: 123 rv['properties'] = self.properties 124 if self.mergeRequests: 125 rv['mergeRequests'] = self.mergeRequests 126 return rv
127