Skip to content

Commit

Permalink
Merge branch 'master' into nine
Browse files Browse the repository at this point in the history
Conflicts:
	master/buildbot/changes/svnpoller.py
	master/buildbot/test/regressions/test_shell_command_properties.py
	master/buildbot/test/unit/test_changes_gerritchangesource.py
  • Loading branch information
djmitche committed Aug 19, 2013
2 parents 02e9dfc + 4a6c106 commit 92754a9
Show file tree
Hide file tree
Showing 39 changed files with 749 additions and 718 deletions.
2 changes: 1 addition & 1 deletion master/buildbot/buildslave/base.py
Expand Up @@ -842,7 +842,7 @@ def _substantiate(self, build):
def start_instance_result(result):
# If we don't report success, then preparation failed.
if not result:
log.msg("Slave '%s' doesn not want to substantiate at this time" % (self.slavename,))
log.msg("Slave '%s' does not want to substantiate at this time" % (self.slavename,))
d = self.substantiation_deferred
self.substantiation_deferred = None
d.callback(False)
Expand Down
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
2 changes: 1 addition & 1 deletion master/buildbot/changes/svnpoller.py
Expand Up @@ -201,7 +201,7 @@ def determine_prefix(output):
try:
doc = xml.dom.minidom.parseString(output)
except xml.parsers.expat.ExpatError:
log.msg("SVNPoller: SVNPoller._determine_prefix_2: ExpatError in '%s'"
log.msg("SVNPoller: SVNPoller.get_prefix: ExpatError in '%s'"
% output)
raise
rootnodes = doc.getElementsByTagName("root")
Expand Down
10 changes: 2 additions & 8 deletions master/buildbot/clients/tryclient.py
Expand Up @@ -866,19 +866,13 @@ def getAvailableBuilderNames(self):
d.addCallback(self._getBuilderNames, self._getBuilderNames2)
return d
if self.connect == "ssh":
print "Cannot get availble builders over ssh."
print "Cannot get available builders over ssh."
sys.exit(1)
raise RuntimeError(
"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 @@ -445,8 +445,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 @@ -475,9 +474,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
12 changes: 2 additions & 10 deletions master/buildbot/process/buildstep.py
Expand Up @@ -30,7 +30,6 @@
EXCEPTION, RETRY, CANCELLED, 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 Expand Up @@ -509,7 +501,7 @@ def setDefaultWorkdir(self, workdir):
pass

def addFactoryArguments(self, **kwargs):
# this is here for backwards compatability
# this is here for backwards compatibility
pass

def _getStepFactory(self):
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
4 changes: 2 additions & 2 deletions master/buildbot/process/properties.py
Expand Up @@ -356,7 +356,7 @@ def getRenderingFor(self, build):


def _getInterpolationList(fmtstring):
# TODO: Verify that no positial substitutions are requested
# TODO: Verify that no positional substitutions are requested
dd = collections.defaultdict(str)
fmtstring % dd
return dd.keys()
Expand Down Expand Up @@ -644,7 +644,7 @@ def renderer(fn):

class _DefaultRenderer(object):
"""
Default IRenderable adaptor. Calls .getRenderingFor if availble, otherwise
Default IRenderable adaptor. Calls .getRenderingFor if available, otherwise
returns argument unchanged.
"""

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/schedulers/trysched.py
Expand Up @@ -281,7 +281,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

0 comments on commit 92754a9

Please sign in to comment.