Ticket #138: 0005-Factor-some-code-to-generate-the-force-stop-forms.patch

File 0005-Factor-some-code-to-generate-the-force-stop-forms.patch, 5.9 KB (added by tsuna, 4 years ago)

[PATCH 05/11] Factor some code to generate the force/stop forms.

  • buildbot/status/web/base.py

    From 4df098129b5e7359954ec267e6d34522c10b3ca5 Mon Sep 17 00:00:00 2001
    From: Benoit Sigoure <tsuna@lrde.epita.fr>
    Date: Thu, 8 Nov 2007 17:20:13 +0100
    Subject: [PATCH 05/11] Factor some code to generate the force/stop forms.
    
    	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@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 b def make_row(label, field): 
    5353    label = html.escape(label) 
    5454    return ROW_TEMPLATE % {"label": label, "field": field} 
    5555 
     56def make_stop_form(stopURL): 
     57    data = """<form action="%s" class='command stopbuild'> 
     58      <p>To stop this build, fill out the following fields and 
     59      click the 'Stop' button</p>\n""" % stopURL 
     60    data += make_row("Your name:", 
     61                     "<input type='text' name='username' />") 
     62    data += make_row("Reason for stopping build:", 
     63                     "<input type='text' name='comments' />") 
     64    data += '<input type="submit" value="Stop Builder" /></form>\n' 
     65    return data 
     66 
     67def make_force_build_form(forceURL): 
     68    data = """<form action="%s" class="command forcebuild"> 
     69      <p>To force a build, fill out the following fields and 
     70      click the 'Force Build' button</p>""" % forceURL 
     71    return (data 
     72      + make_row("Your name:", 
     73                 "<input type='text' name='username' />") 
     74      + make_row("Reason for build:", 
     75                 "<input type='text' name='comments' />") 
     76      + make_row("Branch to build:", 
     77                 "<input type='text' name='branch' />") 
     78      + make_row("Revision to build:", 
     79                 "<input type='text' name='revision' />") 
     80      + '<input type="submit" value="Force Build" /></form>\n') 
     81 
    5682colormap = { 
    5783    'green': '#72ff75', 
    5884    } 
    class Box: 
    149175        if parms.has_key('show_idle'): 
    150176            del parms['show_idle'] 
    151177            self.show_idle = 1 
    152              
     178 
    153179        self.parms = parms 
    154180        # parms is a dict of HTML parameters for the <td> element that will 
    155181        # represent this Event in the waterfall display. 
  • buildbot/status/web/build.py

    diff --git a/buildbot/status/web/build.py b/buildbot/status/web/build.py
    index d3f9a35..52b41ab 100644
    a b from twisted.internet import defer, reactor 
    55 
    66import urllib, time 
    77from twisted.python import log 
    8 from buildbot.status.web.base import HtmlResource, make_row, css_classes, \ 
    9      path_to_builder 
     8from buildbot.status.web.base import HtmlResource, make_row, make_stop_form, \ 
     9     css_classes, path_to_builder 
    1010 
    1111from buildbot.status.web.tests import TestsResource 
    1212from buildbot.status.web.step import StepsResource 
    class StatusResourceBuild(HtmlResource): 
    4848 
    4949            if self.build_control is not None: 
    5050                stopURL = urllib.quote(req.childLink("stop")) 
    51                 data += """ 
    52                 <form action="%s" class='command stopbuild'> 
    53                 <p>To stop this build, fill out the following fields and 
    54                 push the 'Stop' button</p>\n""" % stopURL 
    55                 data += make_row("Your name:", 
    56                                  "<input type='text' name='username' />") 
    57                 data += make_row("Reason for stopping build:", 
    58                                  "<input type='text' name='comments' />") 
    59                 data += """<input type="submit" value="Stop Builder" /> 
    60                 </form> 
    61                 """ 
     51                data += make_stop_form(stopURL) 
    6252 
    6353        if b.isFinished(): 
    6454            results = b.getResults() 
  • buildbot/status/web/builder.py

    diff --git a/buildbot/status/web/builder.py b/buildbot/status/web/builder.py
    index 870d1cf..f67fb45 100644
    a b from twisted.web.util import Redirect 
    66import re, urllib, time 
    77from twisted.python import log 
    88from buildbot import interfaces 
    9 from buildbot.status.web.base import HtmlResource, make_row, OneLineMixin 
     9from buildbot.status.web.base import HtmlResource, make_row, \ 
     10     make_force_build_form, OneLineMixin 
    1011from buildbot.process.base import BuildRequest 
    1112from buildbot.sourcestamp import SourceStamp 
    1213 
    class StatusResourceBuilder(HtmlResource, OneLineMixin): 
    102103 
    103104        if control is not None and connected_slaves: 
    104105            forceURL = urllib.quote(req.childLink("force")) 
    105             data += ( 
    106                 """ 
    107                 <form action='%(forceURL)s' class='command forcebuild'> 
    108                 <p>To force a build, fill out the following fields and 
    109                 push the 'Force Build' button</p>""" 
    110                 + make_row("Your name:", 
    111                            "<input type='text' name='username' />") 
    112                 + make_row("Reason for build:", 
    113                            "<input type='text' name='comments' />") 
    114                 + make_row("Branch to build:", 
    115                            "<input type='text' name='branch' />") 
    116                 + make_row("Revision to build:", 
    117                            "<input type='text' name='revision' />") 
    118                 + """ 
    119                 <input type='submit' value='Force Build' /> 
    120                 </form> 
    121                 """) % {"forceURL": forceURL} 
     106            data += make_force_build_form(forceURL) 
    122107        elif control is not None: 
    123108            data += """ 
    124109            <p>All buildslaves appear to be offline, so it's not possible