Skip to content

Commit

Permalink
Merge commit '10e051422660c9d0b873991cb0890ebf55cfdc80' into jinja
Browse files Browse the repository at this point in the history
Conflicts:
	buildbot/status/web/base.py
	buildbot/status/web/build.py
	buildbot/status/web/builder.py
  • Loading branch information
marcus-sonestedt committed Dec 19, 2009
2 parents 5d9cfb3 + 10e0514 commit 2dbb84a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 33 deletions.
12 changes: 10 additions & 2 deletions buildbot/process/builder.py
Expand Up @@ -10,6 +10,7 @@
from buildbot.status.progress import Expectations
from buildbot.util import now
from buildbot.process import base
from buildbot.process.properties import Properties

(ATTACHING, # slave attached, still checking hostinfo/etc
IDLE, # idle, available for use
Expand Down Expand Up @@ -869,13 +870,20 @@ def requestBuildSoon(self, req):
raise interfaces.NoSlaveError
self.requestBuild(req)

def resubmitBuild(self, bs, reason="<rebuild, no reason given>"):
def resubmitBuild(self, bs, reason="<rebuild, no reason given>", extraProperties=None):
if not bs.isFinished():
return

ss = bs.getSourceStamp(absolute=True)
if extraProperties is None:
properties = bs.getProperties()
else:
# Make a copy so as not to modify the original build.
properties = Properties()
properties.updateFromProperties(bs.getProperties())
properties.updateFromProperties(extraProperties)
req = base.BuildRequest(reason, ss, self.original.name,
properties=bs.getProperties())
properties=properties)
self.requestBuild(req)

def getPendingBuilds(self):
Expand Down
25 changes: 18 additions & 7 deletions buildbot/status/builder.py
Expand Up @@ -334,9 +334,13 @@ def getChunks(self, channels=[], onlyText=False):
# yield() calls.

f = self.getFile()
offset = 0
f.seek(0, 2)
remaining = f.tell()
if not self.finished:
offset = 0
f.seek(0, 2)
remaining = f.tell()
else:
offset = 0
remaining = None

leftover = None
if self.runEntries and (not channels or
Expand All @@ -354,8 +358,12 @@ def _generateChunks(self, f, offset, remaining, leftover,
chunks = []
p = LogFileScanner(chunks.append, channels)
f.seek(offset)
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
if remaining is not None:
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
else:
data = f.read(self.BUFFERSIZE)

offset = f.tell()
while data:
p.dataReceived(data)
Expand All @@ -366,8 +374,11 @@ def _generateChunks(self, f, offset, remaining, leftover,
else:
yield (channel, text)
f.seek(offset)
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
if remaining is not None:
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
else:
data = f.read(self.BUFFERSIZE)
offset = f.tell()
del f

Expand Down
2 changes: 1 addition & 1 deletion buildbot/status/mail.py
Expand Up @@ -113,7 +113,7 @@ def message(attrs):
if attrs['branch']:
source += "[branch %s] " % attrs['branch']
if attrs['revision']:
source += attrs['revision']
source += str(attrs['revision'])
else:
source += "HEAD"
if attrs['patch']:
Expand Down
23 changes: 22 additions & 1 deletion buildbot/status/web/base.py
@@ -1,11 +1,13 @@

import urlparse, urllib, time
import urlparse, urllib, time, re
from zope.interface import Interface
from twisted.web import html, resource, static
from twisted.python import log
from buildbot.status import builder
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION
from buildbot import version, util
import sys, os, cgi
from buildbot.process.properties import Properties

class ITopBox(Interface):
"""I represent a box in the top row of the waterfall display: the one
Expand Down Expand Up @@ -38,6 +40,25 @@ class IHTMLLog(Interface):
None: "",
}


def getAndCheckProperties(req):
"""
Fetch custom build properties from the HTTP request of a "Force build" or
"Resubmit build" HTML form.
Check the names for valid strings, and return None if a problem is found.
Return a new Properties object containing each property found in req.
"""
properties = Properties()
for i in (1,2,3):
pname = req.args.get("property%dname" % i, [""])[0]
pvalue = req.args.get("property%dvalue" % i, [""])[0]
if pname and pvalue:
if not re.match(r'^[\w\.\-\/\~:]*$', pname) \
or not re.match(r'^[\w\.\-\/\~:]*$', pvalue):
log.msg("bad property name='%s', value='%s'" % (pname, pvalue))
return None
properties.setProperty(pname, pvalue, "Force Build Form")
return properties
def td(text="", parms={}, **props):
data = ""
data += " "
Expand Down
8 changes: 5 additions & 3 deletions buildbot/status/web/build.py
Expand Up @@ -6,7 +6,8 @@
import urllib, time
from twisted.python import log
from buildbot.status.web.base import HtmlResource, \
css_classes, path_to_builder, path_to_slave
css_classes, path_to_builder, path_to_slave,
getAndCheckProperties

from buildbot.status.web.step import StepsResource
from buildbot import version, util
Expand Down Expand Up @@ -172,12 +173,13 @@ def rebuild(self, req):
comments = req.args.get("comments", ["<no reason specified>"])[0]
reason = ("The web-page 'rebuild' button was pressed by "
"'%s': %s\n" % (html.escape(name), html.escape(comments)))
if not bc or not b.isFinished():
extraProperties = getAndCheckProperties(req)
if not bc or not b.isFinished() or extraProperties is None:
log.msg("could not rebuild: bc=%s, isFinished=%s"
% (bc, b.isFinished()))
# TODO: indicate an error
else:
bc.resubmitBuild(b, reason)
bc.resubmitBuild(b, reason, extraProperties)
# we're at
# http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
# Where should we send them?
Expand Down
19 changes: 5 additions & 14 deletions buildbot/status/web/builder.py
Expand Up @@ -7,7 +7,8 @@
from twisted.python import log
from buildbot import interfaces
from buildbot.status.web.base import HtmlResource, BuildLineMixin, \
path_to_build, path_to_slave, path_to_builder, path_to_change
path_to_build, path_to_slave, path_to_builder, path_to_change,
getAndCheckProperties
from buildbot.process.base import BuildRequest
from buildbot.process.properties import Properties
from buildbot.sourcestamp import SourceStamp
Expand Down Expand Up @@ -129,12 +130,6 @@ def force(self, req):
reason = req.args.get("comments", ["<no reason specified>"])[0]
branch = req.args.get("branch", [""])[0]
revision = req.args.get("revision", [""])[0]
properties = Properties()
for i in (1,2,3):
pname = req.args.get("prop%dname" % i, [""])[0]
pvalue = req.args.get("prop%dvalue" % i, [""])[0]
if pname and pvalue:
properties.setProperty(pname, pvalue, "Force Build Form")

r = "The web-page 'force build' button was pressed by '%s': %s\n" \
% (html.escape(name), html.escape(reason))
Expand All @@ -159,13 +154,9 @@ def force(self, req):
if not re.match(r'^[\w\.\-\/]*$', revision):
log.msg("bad revision '%s'" % revision)
return Redirect("..")
for p in properties.asList():
key = p[0]
value = p[1]
if not re.match(r'^[\w\.\-\/]*$', key) \
or not re.match(r'^[\w\.\-\/]*$', value):
log.msg("bad property name='%s', value='%s'" % (key, value))
return Redirect("..")
properties = getAndCheckProperties(req)
if properties is None:
return Redirect("..")
if not branch:
branch = None
if not revision:
Expand Down
9 changes: 4 additions & 5 deletions docs/buildbot.texinfo
Expand Up @@ -418,11 +418,10 @@ decision making, where the overhead of sending a lot of commands back
and forth would be inappropriate, but in general the buildmaster is
responsible for everything).

The buildmaster is usually fed @code{Changes} by some sort of version
control system (@pxref{Change Sources}), which may cause builds to be
run. As the builds are performed, various status messages are
produced, which are then sent to any registered Status Targets
(@pxref{Status Delivery}).
The buildmaster is usually fed @code{Changes} by some sort of version control
system (@pxref{Change Sources}), which may cause builds to be run. As the
builds are performed, various status messages are produced, which are then sent
to any registered Status Targets (@pxref{Status Delivery}).

@c @image{FILENAME, WIDTH, HEIGHT, ALTTEXT, EXTENSION}
@image{images/overview,,,Overview Diagram,}
Expand Down

0 comments on commit 2dbb84a

Please sign in to comment.