[Buildbot-commits] buildbot/buildbot/status html.py,1.71,1.72 words.py,1.43,1.44
Brian Warner
warner at users.sourceforge.net
Fri Oct 21 08:03:41 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28628/buildbot/status
Modified Files:
html.py words.py
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-348
Creator: Brian Warner <warner at lothar.com>
add HTML/IRC control over build-on-branch and build-revision
* buildbot/status/words.py (IrcStatusBot.command_FORCE): add
control over --branch and --revision, not that they are always
legal to provide
* buildbot/status/html.py (StatusResourceBuilder.force): same
(StatusResourceBuild.body): display SourceStamp components
* buildbot/scripts/runner.py (ForceOptions): option parser for the
IRC 'force' command, so it can be shared with an eventual
command-line-tool 'buildbot force' mode.
* buildbot/test/test_runner.py (Options.testForceOptions): test it
Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- html.py 20 Oct 2005 22:25:29 -0000 1.71
+++ html.py 21 Oct 2005 08:03:39 -0000 1.72
@@ -4,7 +4,7 @@
from twisted.python import log, components
from twisted.python.util import sibpath
-import urllib
+import urllib, re
from twisted.internet import defer, reactor
from twisted.web.resource import Resource
@@ -309,6 +309,23 @@
% (self.status.getURLForThing(b.getBuilder()),
urllib.quote(b.getBuilder().getName()), b.getNumber(),
html.escape(b.getReason())))
+
+ branch, revision, patch = b.getSourceStamp()
+ data += "<h2>SourceStamp:</h2>\n"
+ data += " <ul>\n"
+ if branch:
+ data += " <li>Branch: %s</li>\n" % html.escape(branch)
+ if revision:
+ data += " <li>Revision: %s</li>\n" % html.escape(revision)
+ if patch:
+ data += " <li>Patch: YES</li>\n" # TODO: provide link to .diff
+ if b.getChanges():
+ data += " <li>Changes: see below</li>\n"
+ if (branch is None and revision is None and patch is None
+ and not b.getChanges()):
+ data += " <li>build of most recent revision</li>\n"
+ data += " </ul>\n"
+
if b.isFinished():
data += "<h4>Buildslave: %s</h4>\n" % html.escape(b.getSlavename())
data += "<h2>Results:</h2>\n"
@@ -442,6 +459,10 @@
"<input type='text' name='username' />")
+ make_row("Reason for build:",
"<input type='text' name='comments' />")
+ + make_row("Branch to build:",
+ "<input type='text' name='branch' />")
+ + make_row("Revision to build:",
+ "<input type='text' name='revision' />")
+ """
<input type='submit' value='Force Build' />
</form>
@@ -467,25 +488,43 @@
def force(self, request):
name = request.args.get("username", ["<unknown>"])[0]
reason = request.args.get("comments", ["<no reason specified>"])[0]
+ branch = request.args.get("branch", [""])[0]
+ revision = request.args.get("revision", [""])[0]
+
r = "The web-page 'force build' button was pressed by '%s': %s\n" \
% (name, reason)
- log.msg("web forcebuild of builder '%s'" % self.builder.name)
- if self.control:
- # TODO: if we can authenticate that a particular User pushed the
- # button, use their name instead of None, so they'll be informed of
- # the results.
- branch = None
- s = SourceStamp(branch=branch)
- req = BuildRequest(r, s, self.builder.getName())
- try:
- self.control.requestBuildSoon(req)
- except interfaces.NoSlaveError:
- # TODO: tell the web user that their request could not be
- # honored
- pass
- else:
+ log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'"
+ % (self.builder.name, branch, revision))
+
+ if not self.control:
# TODO: tell the web user that their request was denied
log.msg("but builder control is disabled")
+ return Redirect("..")
+
+ # keep weird stuff out of the branch and revision strings. TODO:
+ # centralize this somewhere.
+ if not re.match(r'^[\w\.\-\/]*$', branch):
+ log.msg("bad branch '%s'" % branch)
+ return Redirect("..")
+ if not re.match(r'^[\w\.\-\/]*$', revision):
+ log.msg("bad revision '%s'" % revision)
+ return Redirect("..")
+ if branch == "":
+ branch = None
+ if revision == "":
+ revision = None
+
+ # TODO: if we can authenticate that a particular User pushed the
+ # button, use their name instead of None, so they'll be informed of
+ # the results.
+ s = SourceStamp(branch=branch, revision=revision)
+ req = BuildRequest(r, s, self.builder.getName())
+ try:
+ self.control.requestBuildSoon(req)
+ except interfaces.NoSlaveError:
+ # TODO: tell the web user that their request could not be
+ # honored
+ pass
return Redirect("..")
def ping(self, request):
Index: words.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/words.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- words.py 20 Oct 2005 22:25:29 -0000 1.43
+++ words.py 21 Oct 2005 08:03:39 -0000 1.44
@@ -3,7 +3,7 @@
# code to deliver build status through twisted.words (instant messaging
# protocols: irc, etc)
-import traceback, StringIO, re
+import traceback, StringIO, re, shlex
from twisted.internet import protocol, reactor
try:
@@ -21,6 +21,7 @@
from buildbot.process.base import BuildRequest
from buildbot.status import base
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION
+from buildbot.scripts.runner import ForceOptions
class UsageError(ValueError):
def __init__(self, string = "Invalid usage", *more):
@@ -287,11 +288,27 @@
self.reply(reply, "Build details are at %s" % buildurl)
def command_FORCE(self, user, reply, args):
- args = args.split(None, 2)
- if len(args) < 3 or args[0] != 'build':
- raise UsageError, "try 'force build WHICH <REASON>'"
- which = args[1]
- reason = args[2]
+ args = shlex.split(args)
+ if args.pop(0) != "build":
+ raise UsageError("try 'force build WHICH <REASON>'")
+ opts = ForceOptions()
+ opts.parseOptions(args)
+
+ which = opts['builder']
+ branch = opts['branch']
+ revision = opts['revision']
+ reason = opts['reason']
+
+ # keep weird stuff out of the branch and revision strings. TODO:
+ # centralize this somewhere.
+ if branch and not re.match(r'^[\w\.\-\/]*$', branch):
+ log.msg("bad branch '%s'" % branch)
+ self.reply(reply, "sorry, bad branch '%s'" % branch)
+ return
+ if revision and not re.match(r'^[\w\.\-\/]*$', revision):
+ log.msg("bad revision '%s'" % revision)
+ self.reply(reply, "sorry, bad revision '%s'" % revision)
+ return
bc = self.getControl(which)
@@ -303,8 +320,7 @@
r = "forced: by IRC user <%s>: %s" % (user, reason)
# TODO: maybe give certain users the ability to request builds of
# certain branches
- branch = None
- s = SourceStamp(branch=branch)
+ s = SourceStamp(branch=branch, revision=revision)
req = BuildRequest(r, s, which)
try:
bc.requestBuildSoon(req)
More information about the Commits
mailing list