Skip to content

Commit

Permalink
Merge branch 'buildbot-0.8.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Aug 19, 2013
2 parents 5c7625d + 755d0cb commit 4a6c106
Show file tree
Hide file tree
Showing 36 changed files with 735 additions and 696 deletions.
1 change: 1 addition & 0 deletions master/buildbot/buildslave/libvirt.py
Expand Up @@ -14,6 +14,7 @@
# Portions Copyright Buildbot Team Members
# Portions Copyright 2010 Isotoma Limited

from __future__ import absolute_import
import os

from twisted.internet import defer, utils, threads
Expand Down
8 changes: 1 addition & 7 deletions master/buildbot/clients/tryclient.py
Expand Up @@ -867,13 +867,7 @@ def getAvailableBuilderNames(self):
"unknown connecttype '%s', should be 'pb'" % self.connect)

def _getBuilderNames(self, remote, output):
# Older schedulers won't support the properties argument, so only
# attempt to send them when necessary.
properties = self.config.get('properties', {})
if properties:
d = remote.callRemote("getAvailableBuilderNames", properties)
else:
d = remote.callRemote("getAvailableBuilderNames")
d = remote.callRemote("getAvailableBuilderNames")
d.addCallback(self._getBuilderNames2)
return d

Expand Down
7 changes: 3 additions & 4 deletions master/buildbot/process/buildrequestdistributor.py
Expand Up @@ -462,8 +462,7 @@ def _sortBuilders(self, buildernames):
builders = yield defer.maybeDeferred(lambda :
sorter(self.master, builders))
except Exception:
log.msg("Exception prioritizing builders; order unspecified")
log.err(Failure())
log.err(Failure(), "prioritizing builders; order unspecified")

# and return the names
rv = [ b.name for b in builders ]
Expand Down Expand Up @@ -492,9 +491,9 @@ def _activityLoop(self):
bldr_name = self._pending_builders.pop(0)
self.pending_builders_lock.release()

# get the actual builder object
bldr = self.botmaster.builders.get(bldr_name)
try:
# get the actual builder object
bldr = self.botmaster.builders.get(bldr_name)
if bldr:
yield self._maybeStartBuildsOnBuilder(bldr)
except Exception:
Expand Down
10 changes: 1 addition & 9 deletions master/buildbot/process/buildstep.py
Expand Up @@ -30,7 +30,6 @@
EXCEPTION, RETRY, worst_status
from buildbot.process import metrics, properties
from buildbot.util.eventual import eventually
from buildbot.interfaces import BuildSlaveTooOldError

class BuildStepFailed(Exception):
pass
Expand Down Expand Up @@ -362,8 +361,7 @@ def __init__(self, workdir, command, env=None,
usePTY="slave-config", logEnviron=True,
collectStdout=False,collectStderr=False,
interruptSignal=None,
initialStdin=None, decodeRC={0:SUCCESS},
user=None):
initialStdin=None, decodeRC={0:SUCCESS}):

self.command = command # stash .command, set it later
self.fake_command = [w[2] if (isinstance(w, tuple) and len(w) == 3 and w[0] =='obfuscated')
Expand All @@ -386,8 +384,6 @@ def __init__(self, workdir, command, env=None,
}
if interruptSignal is not None:
args['interruptSignal'] = interruptSignal
if user is not None:
args['user'] = user
RemoteCommand.__init__(self, "shell", args, collectStdout=collectStdout,
collectStderr=collectStderr,
decodeRC=decodeRC)
Expand All @@ -399,10 +395,6 @@ def _start(self):
# fixup themselves
if self.step.slaveVersion("shell", "old") == "old":
self.args['dir'] = self.args['workdir']
if ('user' in self.args and
self.step.slaveVersionIsOlderThan("shell", "2.16")):
m = "slave does not support the 'user' parameter"
raise BuildSlaveTooOldError(m)
what = "command '%s' in dir '%s'" % (self.fake_command,
self.args['workdir'])
log.msg(what)
Expand Down
29 changes: 17 additions & 12 deletions master/buildbot/process/factory.py
Expand Up @@ -13,23 +13,22 @@
#
# Copyright Buildbot Team Members

import warnings
from twisted.python import deprecate, versions

from buildbot import interfaces, util
from buildbot.process.build import Build
from buildbot.process.buildstep import BuildStep
from buildbot.steps.source import CVS, SVN
from buildbot.steps.shell import Configure, Compile, Test, PerlModuleTest

class ArgumentsInTheWrongPlace(Exception):
"""When calling BuildFactory.addStep(stepinstance), addStep() only takes
one argument. You passed extra arguments to addStep(), which you probably
intended to pass to your BuildStep constructor instead. For example, you
should do::
f.addStep(ShellCommand(command=['echo','stuff'], haltOnFailure=True))
# deprecated, use BuildFactory.addStep
@deprecate.deprecated(versions.Version("buildbot", 0, 8, 6))
def s(steptype, **kwargs):
# convenience function for master.cfg files, to create step
# specification tuples
return interfaces.IBuildStepFactory(steptype(**kwargs))

instead of::
f.addStep(ShellCommand(command=['echo','stuff']), haltOnFailure=True)
"""

class BuildFactory(util.ComparableMixin):
"""
Expand Down Expand Up @@ -58,7 +57,13 @@ def newBuild(self, requests):
b.setStepFactories(self.steps)
return b

def addStep(self, step):
def addStep(self, step, **kwargs):
if kwargs or (type(step) == type(BuildStep) and issubclass(step, BuildStep)):
warnings.warn(
"Passing a BuildStep subclass to factory.addStep is "
"deprecated. Please pass a BuildStep instance instead.",
DeprecationWarning, stacklevel=2)
step = step(**kwargs)
self.steps.append(interfaces.IBuildStepFactory(step))

def addSteps(self, steps):
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/schedulers/trysched.py
Expand Up @@ -264,7 +264,7 @@ def perspective_try(self, branch, revision, patch, repository, project,
from buildbot.status.client import makeRemote
defer.returnValue(makeRemote(bss))

def perspective_getAvailableBuilderNames(self, properties={}):
def perspective_getAvailableBuilderNames(self):
# Return a list of builder names that are configured
# for the try service
# This is mostly intended for integrating try services
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/scripts/base.py
Expand Up @@ -43,8 +43,8 @@ def getConfigFileFromTac(basedir):
# execute the .tac file to see if its configfile location exists
tacFile = os.path.join(basedir, 'buildbot.tac')
if os.path.exists(tacFile):
# don't mess with the global namespace
tacGlobals = {}
# don't mess with the global namespace, but set __file__ for relocatable buildmasters
tacGlobals = {'__file__' : tacFile}
execfile(tacFile, tacGlobals)
return tacGlobals.get("configfile", "master.cfg")
else:
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/status/status_gerrit.py
Expand Up @@ -93,7 +93,7 @@ def buildStarted(self, builderName, build):

def buildFinished(self, builderName, build, result):
"""Do the SSH gerrit verify command to the server."""
message, verified, reviewed = self.reviewCB(builderName, build, result, self.reviewArg)
message, verified, reviewed = self.reviewCB(builderName, build, result, self.status, self.reviewArg)
self.sendCodeReviews(build, message, verified, reviewed)

def sendCodeReviews(self, build, message, verified=0, reviewed=0):
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/status/web/base.py
Expand Up @@ -110,16 +110,16 @@ def build_get_class(b):
return builder.Results[result]

def path_to_root(request):
# /waterfall : ['waterfall'] -> '/'
# /waterfall : ['waterfall'] -> './'
# /somewhere/lower : ['somewhere', 'lower'] -> '../'
# /somewhere/indexy/ : ['somewhere', 'indexy', ''] -> '../../'
# / : [] -> '/'
# / : [] -> './'
if request.prepath:
segs = len(request.prepath) - 1
else:
segs = 0
root = "../" * segs
return root if len(root) > 0 else "/"
root = "../" * segs if segs else './'
return root

def path_to_authfail(request):
return path_to_root(request) + "authfail"
Expand Down
36 changes: 26 additions & 10 deletions master/buildbot/status/web/baseweb.py
Expand Up @@ -46,8 +46,10 @@
from buildbot.status.web.users import UsersResource
from buildbot.status.web.change_hook import ChangeHookResource
from twisted.cred.portal import IRealm, Portal
from twisted.cred import strcred
from twisted.cred.checkers import ICredentialsChecker
from twisted.cred.credentials import IUsernamePassword
from twisted.web import resource, guard
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse

# this class contains the WebStatus class. Basic utilities are in base.py,
# and specific pages are each in their own module.
Expand Down Expand Up @@ -322,9 +324,25 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=None,

# check for correctness of HTTP auth parameters
if change_hook_auth is not None:
if not isinstance(change_hook_auth, tuple) or len(change_hook_auth) != 2:
config.error("Invalid credentials for change_hook auth")
self.change_hook_auth = change_hook_auth
self.change_hook_auth = []
for checker in change_hook_auth:
if isinstance(checker, str):
try:
checker = strcred.makeChecker(checker)
except Exception, error:
config.error("Invalid change_hook checker description: %s" % (error,))
continue
elif not ICredentialsChecker.providedBy(checker):
config.error("change_hook checker doesn't provide ICredentialChecker: %r" % (checker,))
continue

if IUsernamePassword not in checker.credentialInterfaces:
config.error("change_hook checker doesn't support IUsernamePassword: %r" % (checker,))
continue

self.change_hook_auth.append(checker)
else:
self.change_hook_auth = None

self.orderConsoleByTime = order_console_by_time

Expand Down Expand Up @@ -359,7 +377,8 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=None,
self.change_hook_dialects = change_hook_dialects
resource_obj = ChangeHookResource(dialects=self.change_hook_dialects)
if self.change_hook_auth is not None:
resource_obj = self.setupProtectedResource(resource_obj)
resource_obj = self.setupProtectedResource(
resource_obj, self.change_hook_auth)
self.putChild("change_hook", resource_obj)

# Set default feeds
Expand All @@ -370,7 +389,7 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=None,

self.jinja_loaders = jinja_loaders

def setupProtectedResource(self, resource_obj):
def setupProtectedResource(self, resource_obj, checkers):
class SimpleRealm(object):
"""
A realm which gives out L{ChangeHookResource} instances for authenticated
Expand All @@ -383,10 +402,7 @@ def requestAvatar(self, avatarId, mind, *interfaces):
return (resource.IResource, resource_obj, lambda: None)
raise NotImplementedError()

login, password = self.change_hook_auth
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser(login, password)
portal = Portal(SimpleRealm(), [checker])
portal = Portal(SimpleRealm(), checkers)
credentialFactory = guard.BasicCredentialFactory('Protected area')
wrapper = guard.HTTPAuthSessionWrapper(portal, [credentialFactory])
return wrapper
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/status/web/feeds.py
Expand Up @@ -66,7 +66,7 @@ def render(self, request):
def rfc822_time(tstamp):
res = time.strftime("%%s, %d %%s %Y %H:%M:%S GMT",
tstamp)
res = res % (tstamp.tm_wday, tstamp.tm_mon)
res = res % (_abbr_day[tstamp.tm_wday], _abbr_mon[tstamp.tm_mon])
return res

class FeedResource(XmlResource):
Expand Down
38 changes: 10 additions & 28 deletions master/buildbot/steps/source/p4.py
Expand Up @@ -19,12 +19,11 @@

from twisted.python import log
from twisted.internet import defer
from buildbot import interfaces
from buildbot import interfaces, config
from buildbot.process import buildstep
from buildbot.steps.source import Source
from buildbot.interfaces import BuildSlaveTooOldError
from buildbot.process.properties import Interpolate
from buildbot.config import ConfigErrors
from types import StringType


Expand Down Expand Up @@ -72,38 +71,34 @@ def __init__(self, mode='incremental',

Source.__init__(self, **kwargs)

errors = []
if self.mode not in self.possible_modes:
errors.append("mode %s is not one of %s" % (self.mode, self.possible_modes))
config.error("mode %s is not one of %s" % (self.mode, self.possible_modes))

if not p4viewspec and p4base is None:
errors.append("You must provide p4base or p4viewspec")
config.error("You must provide p4base or p4viewspec")

if p4viewspec and (p4base or p4branch or p4extra_views):
errors.append("Either provide p4viewspec or p4base and p4branch (and optionally p4extra_views")
config.error("Either provide p4viewspec or p4base and p4branch (and optionally p4extra_views")

if p4viewspec and type(p4viewspec) is StringType:
errors.append("p4viewspec must not be a string, and should be a sequence of 2 element sequences")
config.error("p4viewspec must not be a string, and should be a sequence of 2 element sequences")

if not interfaces.IRenderable.providedBy(p4base) and p4base and p4base.endswith('/'):
errors.append('p4base should not end with a trailing / [p4base = %s]' % p4base)
config.error('p4base should not end with a trailing / [p4base = %s]' % p4base)

if not interfaces.IRenderable.providedBy(p4branch) and p4branch and p4branch.endswith('/'):
errors.append('p4branch should not end with a trailing / [p4branch = %s]' % p4branch)
config.error('p4branch should not end with a trailing / [p4branch = %s]' % p4branch)

if (p4branch or p4extra_views) and not p4base:
errors.append('If you specify either p4branch or p4extra_views you must also specify p4base')

if errors:
raise ConfigErrors(errors)
config.error('If you specify either p4branch or p4extra_views you must also specify p4base')

def startVC(self, branch, revision, patch):
if debug_logging:
log.msg('in startVC')

self.revision = revision
self.method = self._getMethod()
self.stdio_log = self.addLog("stdio")
self.stdio_log = self.addLogForRemoteCommands("stdio")

d = self.checkP4()

Expand Down Expand Up @@ -135,10 +130,7 @@ def full(self, _):
yield self._dovccmd(['sync', '#none'])

# Then remove directory.
# NOTE: Not using CompositeStepMixin's runRmdir() as it requires self.rc_log
# to be defined and ran into issues where setting that in _dovccmd would
# yield multiple logs named 'stdio' in the waterfall report..
yield self._rmdir(self.workdir)
yield self.runRmdir(self.workdir)

# Then we need to sync the client
if self.revision:
Expand Down Expand Up @@ -360,13 +352,3 @@ def computeSourceRevision(self, changes):
return None
lastChange = max([int(c.revision) for c in changes])
return lastChange

@defer.inlineCallbacks
def _rmdir(self, dir):
cmd = buildstep.RemoteCommand('rmdir',
{'dir': dir,
'logEnviron': self.logEnviron})
cmd.useLog(self.stdio_log, False)
yield self.runCommand(cmd)
if cmd.rc != 0:
raise buildstep.BuildStepFailed()

0 comments on commit 4a6c106

Please sign in to comment.