def generate_cfg(self): t = _template( "%sslave.cfg.tpl" % BUILDBOT_TMPLS, basedir=os.path.abspath(self.path), masterhost=self.master.host, slavename=self.name, slaveport=self.master.slave_port, slavepasswd=self.passwd, ) cfg = open(os.path.join(self.path, "buildbot.tac"), "w") cfg.write(t) cfg.close()
def generate_cfg(self): buildslaves = "" factories = "" statuses = "" schedulers = "" imports = "" builders = [] modules = [] ct = 1 for slave in self.slaves.all(): # generate the BuildSlave objects buildslaves += "\n BuildSlave('%s', '%s')," % (slave.name, slave.passwd) # create buildfactory b = "%s_%s" % (self.name, slave.name) b = b.replace("-", "__dash__") factories += "%s = factory.BuildFactory()\n" % b for step in slave.steps.all(): if step.type not in modules: modules.append(step.type) factories += "%s.addStep(%s)\n" % (b, _generate_class(step)) # create builder from factory factories += "b%s = {'name': '%s',\n" % (ct, slave.name) factories += " 'slavename': '%s',\n" % slave.name factories += " 'builddir': '%s',\n" % slave.name factories += " 'factory': %s, }\n\n" % b # remember the builders builders.append("b%s" % ct) ct += 1 # generate status for status in self.status.all(): statuses += "c['status'].append(%s)" % _generate_class(status) modules.append(status.type) # generate schedulers for scheduler in self.schedulers.all(): schedulers += "c['scheduler'].append(%s)" % _generate_class(scheduler) modules.append(scheduler.type) # restructure the imports for x in modules: imports += "from %s import %s\n" % (".".join(x.module.split(".")[:-1]), x.module.split(".")[-1]) # generate the template t = _template( "%smaster.cfg.tpl" % BUILDBOT_TMPLS, botname=self.name, webhost=self.host, webport=self.web_port, slaveport=self.slave_port, buildslaves=buildslaves, imports=imports, factories=factories, builders=",".join(builders), statuses=statuses, schedulers=schedulers, ) cfg = open(os.path.join(self.path, "master.cfg"), "w") cfg.write(t) cfg.close()