本文整理汇总了Python中buildbot.status.progress.Expectations.expectedBuildTime方法的典型用法代码示例。如果您正苦于以下问题:Python Expectations.expectedBuildTime方法的具体用法?Python Expectations.expectedBuildTime怎么用?Python Expectations.expectedBuildTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buildbot.status.progress.Expectations
的用法示例。
在下文中一共展示了Expectations.expectedBuildTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Builder
# 需要导入模块: from buildbot.status.progress import Expectations [as 别名]
# 或者: from buildbot.status.progress.Expectations import expectedBuildTime [as 别名]
#.........这里部分代码省略.........
# nothing in particular to do with this deferred, so just log it if
# it fails..
d.addErrback(log.err, 'while marking build requests as completed')
if sb.slave:
sb.slave.releaseLocks()
self.updateBigStatus()
@defer.inlineCallbacks
def _maybeBuildsetsComplete(self, requests):
# inform the master that we may have completed a number of buildsets
for br in requests:
yield self.master.maybeBuildsetComplete(br.bsid)
def _resubmit_buildreqs(self, build):
brids = [br.id for br in build.requests]
return self.master.db.buildrequests.unclaimBuildRequests(brids)
def setExpectations(self, progress):
"""Mark the build as successful and update expectations for the next
build. Only call this when the build did not fail in any way that
would invalidate the time expectations generated by it. (if the
compile failed and thus terminated early, we can't use the last
build to predict how long the next one will take).
"""
if self.expectations:
self.expectations.update(progress)
else:
# the first time we get a good build, create our Expectations
# based upon its results
self.expectations = Expectations(progress)
log.msg("new expectations: %s seconds" % \
self.expectations.expectedBuildTime())
# Build Creation
@defer.inlineCallbacks
def maybeStartBuild(self):
# This method is called by the botmaster whenever this builder should
# check for and potentially start new builds. Do not call this method
# directly - use master.botmaster.maybeStartBuildsForBuilder, or one
# of the other similar methods if more appropriate
# first, if we're not running, then don't start builds; stopService
# uses this to ensure that any ongoing maybeStartBuild invocations
# are complete before it stops.
if not self.running:
return
# Check for available slaves. If there are no available slaves, then
# there is no sense continuing
available_slavebuilders = [ sb for sb in self.slaves
if sb.isAvailable() ]
if not available_slavebuilders:
self.updateBigStatus()
return
# now, get the available build requests
unclaimed_requests = \
yield self.master.db.buildrequests.getBuildRequests(
buildername=self.name, claimed=False)
if not unclaimed_requests:
self.updateBigStatus()
return
示例2: Builder
# 需要导入模块: from buildbot.status.progress import Expectations [as 别名]
# 或者: from buildbot.status.progress.Expectations import expectedBuildTime [as 别名]
#.........这里部分代码省略.........
d.addCallback(_ping)
d.addCallback(self._startBuild_1, build, sb)
return d
d.addCallback(_prepared)
return d
def _startBuild_1(self, res, build, sb):
if not res:
return self._startBuildFailed("slave ping failed", build, sb)
# The buildslave is ready to go. sb.buildStarted() sets its state to
# BUILDING (so we won't try to use it for any other builds). This
# gets set back to IDLE by the Build itself when it finishes.
sb.buildStarted()
d = sb.remote.callRemote("startBuild")
d.addCallbacks(self._startBuild_2, self._startBuildFailed,
callbackArgs=(build,sb), errbackArgs=(build,sb))
return d
def _startBuild_2(self, res, build, sb):
# create the BuildStatus object that goes with the Build
bs = self.builder_status.newBuild()
# start the build. This will first set up the steps, then tell the
# BuildStatus that it has started, which will announce it to the
# world (through our BuilderStatus object, which is its parent).
# Finally it will start the actual build process.
bids = [self.db.build_started(req.id, bs.number) for req in build.requests]
d = build.startBuild(bs, self.expectations, sb)
d.addCallback(self.buildFinished, sb, bids)
# this shouldn't happen. if it does, the slave will be wedged
d.addErrback(log.err)
return build # this is the IBuildControl
def _startBuildFailed(self, why, build, sb):
# put the build back on the buildable list
log.msg("I tried to tell the slave that the build %s started, but "
"remote_startBuild failed: %s" % (build, why))
# release the slave. This will queue a call to maybeStartBuild, which
# will fire after other notifyOnDisconnect handlers have marked the
# slave as disconnected (so we don't try to use it again).
sb.buildFinished()
log.msg("re-queueing the BuildRequest")
self.building.remove(build)
self._resubmit_buildreqs(build).addErrback(log.err)
def setupProperties(self, props):
props.setProperty("buildername", self.name, "Builder")
if len(self.properties) > 0:
for propertyname in self.properties:
props.setProperty(propertyname, self.properties[propertyname], "Builder")
def buildFinished(self, build, sb, bids):
"""This is called when the Build has finished (either success or
failure). Any exceptions during the build are reported with
results=FAILURE, not with an errback."""
# by the time we get here, the Build has already released the slave
# (which queues a call to maybeStartBuild)
self.db.builds_finished(bids)
results = build.build_status.getResults()
self.building.remove(build)
if results == RETRY:
self._resubmit_buildreqs(build).addErrback(log.err) # returns Deferred
else:
brids = [br.id for br in build.requests]
self.db.retire_buildrequests(brids, results)
if sb.slave:
sb.slave.releaseLocks()
self.triggerNewBuildCheck()
def _resubmit_buildreqs(self, build):
brids = [br.id for br in build.requests]
return self.db.resubmit_buildrequests(brids)
def setExpectations(self, progress):
"""Mark the build as successful and update expectations for the next
build. Only call this when the build did not fail in any way that
would invalidate the time expectations generated by it. (if the
compile failed and thus terminated early, we can't use the last
build to predict how long the next one will take).
"""
if self.expectations:
self.expectations.update(progress)
else:
# the first time we get a good build, create our Expectations
# based upon its results
self.expectations = Expectations(progress)
log.msg("new expectations: %s seconds" % \
self.expectations.expectedBuildTime())
def shutdownSlave(self):
if self.remote:
self.remote.callRemote("shutdown")
示例3: Builder
# 需要导入模块: from buildbot.status.progress import Expectations [as 别名]
# 或者: from buildbot.status.progress.Expectations import expectedBuildTime [as 别名]
#.........这里部分代码省略.........
@param build: the L{base.Build} to start
@param sb: the L{SlaveBuilder} which will host this build
@return: a Deferred which fires with a
L{buildbot.interfaces.IBuildControl} that can be used to stop the
Build, or to access a L{buildbot.interfaces.IBuildStatus} which will
watch the Build as it runs. """
self.building.append(build)
self.updateBigStatus()
log.msg("starting build %s using slave %s" % (build, sb))
d = sb.prepare(self.builder_status)
def _ping(ign):
# ping the slave to make sure they're still there. If they're
# fallen off the map (due to a NAT timeout or something), this
# will fail in a couple of minutes, depending upon the TCP
# timeout. TODO: consider making this time out faster, or at
# least characterize the likely duration.
log.msg("starting build %s.. pinging the slave %s" % (build, sb))
return sb.ping(self.START_BUILD_TIMEOUT)
d.addCallback(_ping)
d.addCallback(self._startBuild_1, build, sb)
return d
def _startBuild_1(self, res, build, sb):
if not res:
return self._startBuildFailed("slave ping failed", build, sb)
# The buildslave is ready to go. sb.buildStarted() sets its state to
# BUILDING (so we won't try to use it for any other builds). This
# gets set back to IDLE by the Build itself when it finishes.
sb.buildStarted()
d = sb.remote.callRemote("startBuild")
d.addCallbacks(self._startBuild_2, self._startBuildFailed,
callbackArgs=(build,sb), errbackArgs=(build,sb))
return d
def _startBuild_2(self, res, build, sb):
# create the BuildStatus object that goes with the Build
bs = self.builder_status.newBuild()
# start the build. This will first set up the steps, then tell the
# BuildStatus that it has started, which will announce it to the
# world (through our BuilderStatus object, which is its parent).
# Finally it will start the actual build process.
d = build.startBuild(bs, self.expectations, sb)
d.addCallback(self.buildFinished, sb)
d.addErrback(log.err) # this shouldn't happen. if it does, the slave
# will be wedged
for req in build.requests:
req.buildStarted(build, bs)
return build # this is the IBuildControl
def _startBuildFailed(self, why, build, sb):
# put the build back on the buildable list
log.msg("I tried to tell the slave that the build %s started, but "
"remote_startBuild failed: %s" % (build, why))
# release the slave. This will queue a call to maybeStartBuild, which
# will fire after other notifyOnDisconnect handlers have marked the
# slave as disconnected (so we don't try to use it again).
sb.buildFinished()
log.msg("re-queueing the BuildRequest")
self.building.remove(build)
for req in build.requests:
self.buildable.insert(0, req) # the interrupted build gets first
# priority
self.builder_status.addBuildRequest(req.status)
def buildFinished(self, build, sb):
"""This is called when the Build has finished (either success or
failure). Any exceptions during the build are reported with
results=FAILURE, not with an errback."""
# by the time we get here, the Build has already released the slave
# (which queues a call to maybeStartBuild)
self.building.remove(build)
for req in build.requests:
req.finished(build.build_status)
def setExpectations(self, progress):
"""Mark the build as successful and update expectations for the next
build. Only call this when the build did not fail in any way that
would invalidate the time expectations generated by it. (if the
compile failed and thus terminated early, we can't use the last
build to predict how long the next one will take).
"""
if self.expectations:
self.expectations.update(progress)
else:
# the first time we get a good build, create our Expectations
# based upon its results
self.expectations = Expectations(progress)
log.msg("new expectations: %s seconds" % \
self.expectations.expectedBuildTime())
def shutdownSlave(self):
if self.remote:
self.remote.callRemote("shutdown")
示例4: Builder
# 需要导入模块: from buildbot.status.progress import Expectations [as 别名]
# 或者: from buildbot.status.progress.Expectations import expectedBuildTime [as 别名]
#.........这里部分代码省略.........
self._notify_completions(build.requests, results,
complete_at_epoch))
# nothing in particular to do with this deferred, so just log it if
# it fails..
d.addErrback(log.err, 'while marking build requests as completed')
if sb.slave:
sb.slave.releaseLocks()
self.updateBigStatus()
@defer.inlineCallbacks
def _notify_completions(self, requests, results, complete_at_epoch):
updates = self.master.data.updates
# send a message for each request
for br in requests:
updates.completeBuildRequests([br.id], results,
epoch2datetime(complete_at_epoch))
# check for completed buildsets -- one call for each build request with
# a unique bsid
seen_bsids = set()
for br in requests:
if br.bsid in seen_bsids:
continue
seen_bsids.add(br.bsid)
yield updates.maybeBuildsetComplete(br.bsid)
def _resubmit_buildreqs(self, build):
brids = [br.id for br in build.requests]
d = self.master.data.updates.unclaimBuildRequests(brids)
@d.addCallback
def notify(_):
pass # XXX method does not exist
# self._msg_buildrequests_unclaimed(build.requests)
return d
def setExpectations(self, progress):
"""Mark the build as successful and update expectations for the next
build. Only call this when the build did not fail in any way that
would invalidate the time expectations generated by it. (if the
compile failed and thus terminated early, we can't use the last
build to predict how long the next one will take).
"""
if self.expectations:
self.expectations.update(progress)
else:
# the first time we get a good build, create our Expectations
# based upon its results
self.expectations = Expectations(progress)
log.msg("new expectations: %s seconds" %
self.expectations.expectedBuildTime())
# Build Creation
@defer.inlineCallbacks
def maybeStartBuild(self, slavebuilder, breqs, _reactor=reactor):
# This method is called by the botmaster whenever this builder should
# start a set of buildrequests on a slave. Do not call this method
# directly - use master.botmaster.maybeStartBuildsForBuilder, or one of
# the other similar methods if more appropriate
# first, if we're not running, then don't start builds; stopService
# uses this to ensure that any ongoing maybeStartBuild invocations
# are complete before it stops.
if not self.running:
defer.returnValue(False)
return
# If the build fails from here on out (e.g., because a slave has failed),
# it will be handled outside of this function. TODO: test that!
build_started = yield self._startBuildFor(slavebuilder, breqs)
defer.returnValue(build_started)
# a few utility functions to make the maybeStartBuild a bit shorter and
# easier to read
def getMergeRequestsFn(self):
"""Helper function to determine which mergeRequests function to use
from L{_mergeRequests}, or None for no merging"""
# first, seek through builder, global, and the default
mergeRequests_fn = self.config.mergeRequests
if mergeRequests_fn is None:
mergeRequests_fn = self.master.config.mergeRequests
if mergeRequests_fn is None:
mergeRequests_fn = True
# then translate False and True properly
if mergeRequests_fn is False:
mergeRequests_fn = None
elif mergeRequests_fn is True:
mergeRequests_fn = Builder._defaultMergeRequestFn
return mergeRequests_fn
def _defaultMergeRequestFn(self, req1, req2):
return req1.canBeMergedWith(req2)
示例5: Builder
# 需要导入模块: from buildbot.status.progress import Expectations [as 别名]
# 或者: from buildbot.status.progress.Expectations import expectedBuildTime [as 别名]
#.........这里部分代码省略.........
# it fails..
d.addErrback(log.err, 'while marking build requests as completed')
if sb.slave:
sb.slave.releaseLocks()
@defer.deferredGenerator
def _maybeBuildsetsComplete(self, requests):
# inform the master that we may have completed a number of buildsets
for br in requests:
wfd = defer.waitForDeferred(
self.master.maybeBuildsetComplete(br.bsid))
yield wfd
wfd.getResult()
def _resubmit_buildreqs(self, build):
brids = [br.id for br in build.requests]
return self.db.buildrequests.unclaimBuildRequests(brids)
def setExpectations(self, progress):
"""Mark the build as successful and update expectations for the next
build. Only call this when the build did not fail in any way that
would invalidate the time expectations generated by it. (if the
compile failed and thus terminated early, we can't use the last
build to predict how long the next one will take).
"""
if self.expectations:
self.expectations.update(progress)
else:
# the first time we get a good build, create our Expectations
# based upon its results
self.expectations = Expectations(progress)
log.msg("new expectations: %s seconds" % \
self.expectations.expectedBuildTime())
# Build Creation
@defer.deferredGenerator
def maybeStartBuild(self):
# This method is called by the botmaster whenever this builder should
# check for and potentially start new builds. Do not call this method
# directly - use master.botmaster.maybeStartBuildsForBuilder, or one
# of the other similar methods if more appropriate
# first, if we're not running, then don't start builds; stopService
# uses this to ensure that any ongoing maybeStartBuild invocations
# are complete before it stops.
if not self.running:
return
# Check for available slaves. If there are no available slaves, then
# there is no sense continuing
available_slavebuilders = [ sb for sb in self.slaves
if sb.isAvailable() ]
if not available_slavebuilders:
self.updateBigStatus()
return
# now, get the available build requests
wfd = defer.waitForDeferred(
self.master.db.buildrequests.getBuildRequests(
buildername=self.name, claimed=False))
yield wfd
unclaimed_requests = wfd.getResult()
# sort by submitted_at, so the first is the oldest