[Buildbot-devel] [PATCH 05/11] Factor some code to generate the force/stop forms.
Benoit Sigoure
tsuna at lrde.epita.fr
Fri Nov 16 17:12:55 UTC 2007
This will help for the next patch.
* buildbot/status/web/base.py (make_stop_form)
(make_force_build_form): New.
* status/web/build.py (StatusResourceBuild.body),
* status/web/builder.py (StatusResourceBuilder.body): Use them.
Signed-off-by: Benoit Sigoure <tsuna at lrde.epita.fr>
---
buildbot/status/web/base.py | 28 +++++++++++++++++++++++++++-
buildbot/status/web/build.py | 16 +++-------------
buildbot/status/web/builder.py | 21 +++------------------
3 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/buildbot/status/web/base.py b/buildbot/status/web/base.py
index 003e25d..565a135 100644
--- a/buildbot/status/web/base.py
+++ b/buildbot/status/web/base.py
@@ -53,6 +53,32 @@ def make_row(label, field):
label = html.escape(label)
return ROW_TEMPLATE % {"label": label, "field": field}
+def make_stop_form(stopURL):
+ data = """<form action="%s" class='command stopbuild'>
+ <p>To stop this build, fill out the following fields and
+ click the 'Stop' button</p>\n""" % stopURL
+ data += make_row("Your name:",
+ "<input type='text' name='username' />")
+ data += make_row("Reason for stopping build:",
+ "<input type='text' name='comments' />")
+ data += '<input type="submit" value="Stop Builder" /></form>\n'
+ return data
+
+def make_force_build_form(forceURL):
+ data = """<form action="%s" class="command forcebuild">
+ <p>To force a build, fill out the following fields and
+ click the 'Force Build' button</p>""" % forceURL
+ return (data
+ + make_row("Your name:",
+ "<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>\n')
+
colormap = {
'green': '#72ff75',
}
@@ -149,7 +175,7 @@ class Box:
if parms.has_key('show_idle'):
del parms['show_idle']
self.show_idle = 1
-
+
self.parms = parms
# parms is a dict of HTML parameters for the <td> element that will
# represent this Event in the waterfall display.
diff --git a/buildbot/status/web/build.py b/buildbot/status/web/build.py
index d3f9a35..52b41ab 100644
--- a/buildbot/status/web/build.py
+++ b/buildbot/status/web/build.py
@@ -5,8 +5,8 @@ from twisted.internet import defer, reactor
import urllib, time
from twisted.python import log
-from buildbot.status.web.base import HtmlResource, make_row, css_classes, \
- path_to_builder
+from buildbot.status.web.base import HtmlResource, make_row, make_stop_form, \
+ css_classes, path_to_builder
from buildbot.status.web.tests import TestsResource
from buildbot.status.web.step import StepsResource
@@ -48,17 +48,7 @@ class StatusResourceBuild(HtmlResource):
if self.build_control is not None:
stopURL = urllib.quote(req.childLink("stop"))
- data += """
- <form action="%s" class='command stopbuild'>
- <p>To stop this build, fill out the following fields and
- push the 'Stop' button</p>\n""" % stopURL
- data += make_row("Your name:",
- "<input type='text' name='username' />")
- data += make_row("Reason for stopping build:",
- "<input type='text' name='comments' />")
- data += """<input type="submit" value="Stop Builder" />
- </form>
- """
+ data += make_stop_form(stopURL)
if b.isFinished():
results = b.getResults()
diff --git a/buildbot/status/web/builder.py b/buildbot/status/web/builder.py
index 870d1cf..f67fb45 100644
--- a/buildbot/status/web/builder.py
+++ b/buildbot/status/web/builder.py
@@ -6,7 +6,8 @@ from twisted.web.util import Redirect
import re, urllib, time
from twisted.python import log
from buildbot import interfaces
-from buildbot.status.web.base import HtmlResource, make_row, OneLineMixin
+from buildbot.status.web.base import HtmlResource, make_row, \
+ make_force_build_form, OneLineMixin
from buildbot.process.base import BuildRequest
from buildbot.sourcestamp import SourceStamp
@@ -102,23 +103,7 @@ class StatusResourceBuilder(HtmlResource, OneLineMixin):
if control is not None and connected_slaves:
forceURL = urllib.quote(req.childLink("force"))
- data += (
- """
- <form action='%(forceURL)s' class='command forcebuild'>
- <p>To force a build, fill out the following fields and
- push the 'Force Build' button</p>"""
- + make_row("Your name:",
- "<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>
- """) % {"forceURL": forceURL}
+ data += make_force_build_form(forceURL)
elif control is not None:
data += """
<p>All buildslaves appear to be offline, so it's not possible
--
1.5.3.5.654.gdd5ec
More information about the devel
mailing list