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

Source Code for Module buildbot.config

 1  from buildbot.util import safeTranslate 
 2   
 3   
4 -class BuilderConfig:
5 """ 6 7 Used in config files to specify a builder - this can be subclassed by users 8 to add extra config args, set defaults, or whatever. It is converted to a 9 dictionary for consumption by the buildmaster at config time. 10 11 """ 12
13 - def __init__(self, 14 name=None, 15 slavename=None, 16 slavenames=None, 17 builddir=None, 18 slavebuilddir=None, 19 factory=None, 20 category=None, 21 nextSlave=None, 22 nextBuild=None, 23 locks=None, 24 env=None, 25 properties=None):
26 27 # name is required, and can't start with '_' 28 if not name or type(name) not in (str, unicode): 29 raise ValueError("builder's name is required") 30 if name[0] == '_': 31 raise ValueError("builder names must not start with an " 32 "underscore: " + name) 33 self.name = name 34 35 # factory is required 36 if factory is None: 37 raise ValueError("builder's factory is required") 38 self.factory = factory 39 40 # slavenames can be a single slave name or a list, and should also 41 # include slavename, if given 42 if type(slavenames) is str: 43 slavenames = [ slavenames ] 44 if slavenames: 45 if type(slavenames) is not list: 46 raise TypeError("slavenames must be a list or a string") 47 else: 48 slavenames = [] 49 if slavename: 50 if type(slavename) != str: 51 raise TypeError("slavename must be a string") 52 slavenames = slavenames + [ slavename ] 53 if not slavenames: 54 raise ValueError("at least one slavename is required") 55 self.slavenames = slavenames 56 57 # builddir defaults to name 58 if builddir is None: 59 builddir = safeTranslate(name) 60 self.builddir = builddir 61 62 # slavebuilddir defaults to builddir 63 if slavebuilddir is None: 64 slavebuilddir = builddir 65 self.slavebuilddir = slavebuilddir 66 67 # remainder are optional 68 assert category is None or isinstance(category, str) 69 self.category = category 70 self.nextSlave = nextSlave 71 self.nextBuild = nextBuild 72 self.locks = locks 73 self.env = env 74 self.properties = properties
75
76 - def getConfigDict(self):
77 rv = { 78 'name': self.name, 79 'slavenames': self.slavenames, 80 'factory': self.factory, 81 'builddir': self.builddir, 82 'slavebuilddir': self.slavebuilddir, 83 } 84 if self.category: 85 rv['category'] = self.category 86 if self.nextSlave: 87 rv['nextSlave'] = self.nextSlave 88 if self.nextBuild: 89 rv['nextBuild'] = self.nextBuild 90 if self.locks: 91 rv['locks'] = self.locks 92 if self.env: 93 rv['env'] = self.env 94 if self.properties: 95 rv['properties'] = self.properties 96 return rv
97