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