Mercurial > hg > autobot
view autobot/config.py @ 128:95b8fec83ad7
remove pdb
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 23 Jan 2011 10:49:36 -0800 |
parents | 2a55644b9948 |
children | 700693fad00a |
line wrap: on
line source
""" 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, default in ('slaveport', 9010), ('htmlport', 8010): self.master[port] = int(self.master.get(port) or default) # get section information 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:<factory>]) 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]) if __name__ == '__main__': main()