# HG changeset patch # User Jeff Hammel # Date 1294859632 28800 # Node ID 86e65422f31ae50b399da27c6e7372f27424a851 # Parent 42cdcb431462d45e0c5061e740e3982b41a070f2 have some sort of working configuration parser....lets roll with it diff -r 42cdcb431462 -r 86e65422f31a autobot/config.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autobot/config.py Wed Jan 12 11:13:52 2011 -0800 @@ -0,0 +1,70 @@ +""" +tools for interpolating buildbot config +""" + +import sys +from projects import factories +from ConfigParser import RawConfigParser + +class BuildbotIniConfig(object): + """ + class for getting a (for now, autobot-specific) + buildbot configuration from an .ini file + """ + + def __init__(self, filename): + self.parser = RawConfigParser() + self.parser.read(filename) + + # get global information + master = ':master:' + self.master = self.section_dict(master) + for port in 'slaveport', 'htmlport': + self.master[port] = int(self.master.get(port) or 9010) + + self.slaves = {} + self.args = {} + for section in self.parser.sections(): + + # ignore master section -- we've already dealt with that + if section == master: + continue + + # get slave + if section.startswith('slave:'): + name = section.split('slave:', 1)[-1] + slave_dict = self.master.copy() + slave_dict.update(self.section_dict(section)) + assert 'password' in slave_dict, 'Slave %s: must provide a password' + factories = slave_dict.get('factories', '') + factories = factories.split() + if factories == ['']: + factories = [] + self.slaves[name] = {'password': slave_dict['password'], + 'factories': factories } + continue + + # get factories + self.args[section] = self.section_dict(section) + + # TODO: schedulers + sources ([source:]) + + def section_dict(self, section): + """ + returns the section as a dict + """ + if section in self.parser.sections(): + return dict(self.parser.items(section)) + else: + return {} + +def main(args=sys.argv[1:]): + """parse the configuration, mostly for testing purposes""" + if len(args) != 1: + print 'Please provide an .ini file to try to parse' + sys.exit(1) + config = BuildbotIniConfig(args[0]) + import pdb; pdb.set_trace() + +if __name__ == '__main__': + main() diff -r 42cdcb431462 -r 86e65422f31a autobot/template/master/master.cfg --- a/autobot/template/master/master.cfg Tue Jan 11 17:43:09 2011 -0800 +++ b/autobot/template/master/master.cfg Wed Jan 12 11:13:52 2011 -0800 @@ -48,6 +48,6 @@ c['status'].append(html.WebStatus(http_port={{htmlport}}, authz=authz)) ####### PROJECT IDENTITY -c['projectName'] = "Buildbot" +c['projectName'] = "autobot" c['projectURL'] = "http://buildbot.sourceforge.net/" c['buildbotURL'] = "http://localhost:{{htmlport}}/"