本文整理汇总了Python中buildbot.master.BuildMaster.loadConfig方法的典型用法代码示例。如果您正苦于以下问题:Python BuildMaster.loadConfig方法的具体用法?Python BuildMaster.loadConfig怎么用?Python BuildMaster.loadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buildbot.master.BuildMaster
的用法示例。
在下文中一共展示了BuildMaster.loadConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSteps
# 需要导入模块: from buildbot.master import BuildMaster [as 别名]
# 或者: from buildbot.master.BuildMaster import loadConfig [as 别名]
def testSteps(self):
m = BuildMaster(".")
m.loadConfig(cfg1)
b = m.botmaster.builders["builder1"]
steps = b.buildFactory.steps
self.failUnlessEqual(len(steps), 4)
self.failUnlessExpectedShell(steps[0], command="echo yes")
self.failUnlessExpectedShell(steps[1], defaults=False, command="old-style")
self.failUnlessExpectedDarcs(steps[2], repourl="http://buildbot.net/repos/trunk")
self.failUnlessExpectedShell(steps[3], defaults=False, command="echo old-style")
示例2: check_master_cfg
# 需要导入模块: from buildbot.master import BuildMaster [as 别名]
# 或者: from buildbot.master.BuildMaster import loadConfig [as 别名]
def check_master_cfg(self):
from buildbot.master import BuildMaster
from twisted.python import log, failure
master_cfg = os.path.join(self.basedir, "master.cfg")
if not os.path.exists(master_cfg):
if not self.quiet:
print "No master.cfg found"
return 1
# side-effects of loading the config file:
# for each Builder defined in c['builders'], if the status directory
# didn't already exist, it will be created, and the
# $BUILDERNAME/builder pickle might be created (with a single
# "builder created" event).
# we put basedir in front of sys.path, because that's how the
# buildmaster itself will run, and it is quite common to have the
# buildmaster import helper classes from other .py files in its
# basedir.
if sys.path[0] != self.basedir:
sys.path.insert(0, self.basedir)
m = BuildMaster(self.basedir)
# we need to route log.msg to stdout, so any problems can be seen
# there. But if everything goes well, I'd rather not clutter stdout
# with log messages. So instead we add a logObserver which gathers
# messages and only displays them if something goes wrong.
messages = []
log.addObserver(messages.append)
try:
# this will raise an exception if there's something wrong with
# the config file. Note that this BuildMaster instance is never
# started, so it won't actually do anything with the
# configuration.
m.loadConfig(open(master_cfg, "r"))
except:
f = failure.Failure()
if not self.quiet:
print
for m in messages:
print "".join(m['message'])
print f
print
print "An error was detected in the master.cfg file."
print "Please correct the problem and run 'buildbot upgrade-master' again."
print
return 1
return 0
示例3: ConfigTest
# 需要导入模块: from buildbot.master import BuildMaster [as 别名]
# 或者: from buildbot.master.BuildMaster import loadConfig [as 别名]
class ConfigTest(unittest.TestCase):
def setUp(self):
# this class generates several deprecation warnings, which the user
# doesn't need to see.
warnings.simplefilter('ignore', exceptions.DeprecationWarning)
self.buildmaster = BuildMaster(".")
def failUnlessListsEquivalent(self, list1, list2):
l1 = list1[:]
l1.sort()
l2 = list2[:]
l2.sort()
self.failUnlessEqual(l1, l2)
def servers(self, s, types):
# perform a recursive search of s.services, looking for instances of
# twisted.application.internet.TCPServer, then extract their .args
# values to find the TCP ports they want to listen on
for child in s:
if service.IServiceCollection.providedBy(child):
for gc in self.servers(child, types):
yield gc
if isinstance(child, types):
yield child
def TCPports(self, s):
return list(self.servers(s, internet.TCPServer))
def UNIXports(self, s):
return list(self.servers(s, internet.UNIXServer))
def TCPclients(self, s):
return list(self.servers(s, internet.TCPClient))
def checkPorts(self, svc, expected):
"""Verify that the TCPServer and UNIXServer children of the given
service have the expected portnum/pathname and factory classes. As a
side-effect, return a list of servers in the same order as the
'expected' list. This can be used to verify properties of the
factories contained therein."""
expTCP = [e for e in expected if type(e[0]) == int]
expUNIX = [e for e in expected if type(e[0]) == str]
haveTCP = [(p.args[0], p.args[1].__class__)
for p in self.TCPports(svc)]
haveUNIX = [(p.args[0], p.args[1].__class__)
for p in self.UNIXports(svc)]
self.failUnlessListsEquivalent(expTCP, haveTCP)
self.failUnlessListsEquivalent(expUNIX, haveUNIX)
ret = []
for e in expected:
for have in self.TCPports(svc) + self.UNIXports(svc):
if have.args[0] == e[0]:
ret.append(have)
continue
assert(len(ret) == len(expected))
return ret
def testEmpty(self):
self.failUnlessRaises(KeyError, self.buildmaster.loadConfig, "")
def testSimple(self):
# covers slavePortnum, base checker passwords
master = self.buildmaster
master.loadChanges()
master.loadConfig(emptyCfg)
# note: this doesn't actually start listening, because the app
# hasn't been started running
self.failUnlessEqual(master.slavePortnum, "tcp:9999")
self.checkPorts(master, [(9999, pb.PBServerFactory)])
self.failUnlessEqual(list(master.change_svc), [])
self.failUnlessEqual(master.botmaster.builders, {})
self.failUnlessEqual(master.checker.users,
{"change": "changepw"})
self.failUnlessEqual(master.projectName, "dummy project")
self.failUnlessEqual(master.projectURL, "http://dummy.example.com")
self.failUnlessEqual(master.buildbotURL,
"http://dummy.example.com/buildbot")
def testSlavePortnum(self):
master = self.buildmaster
master.loadChanges()
master.loadConfig(emptyCfg)
self.failUnlessEqual(master.slavePortnum, "tcp:9999")
ports = self.checkPorts(master, [(9999, pb.PBServerFactory)])
p = ports[0]
master.loadConfig(emptyCfg)
self.failUnlessEqual(master.slavePortnum, "tcp:9999")
ports = self.checkPorts(master, [(9999, pb.PBServerFactory)])
self.failUnlessIdentical(p, ports[0],
"the slave port was changed even " + \
"though the configuration was not")
master.loadConfig(emptyCfg + "c['slavePortnum'] = 9000\n")
self.failUnlessEqual(master.slavePortnum, "tcp:9000")
ports = self.checkPorts(master, [(9000, pb.PBServerFactory)])
self.failIf(p is ports[0],
"slave port was unchanged but configuration was changed")
#.........这里部分代码省略.........