[Buildbot-devel] Buildbot-devel Digest, Vol 41, Issue 10

Zhu Jia Cheng realalien at gmail.com
Wed Sep 16 08:50:12 UTC 2009

Hi! All,
    I did some modification on my local Buildbot's code, but I am not
sureif my way of hacking breaks some rules or produces bad-smelling
code, or if
there is a better way there (I found it's quite hard to write a test first
or draw a UML diagram, considering my 5 month exp. in Python ). Would
someone be kind enough to take a look and give some suggestions? (
LinesOfCode < 20)

    The original idea was to stop all the pending builds except the last
building/pending one on each builder when there are lots of long-duration
builds queuing(sometimes a critical fix waits behind some "to-be-failed"
 pending ones.)

     My solution is as follows, (see Bold line),  I will be very grateful
for any suggestions.
* modifying code which handles /builders/_all/stop.
in:   status.web.builder , class StatusResourceAllBuilders
def stop(self, req):
        for bname in self.status.getBuilderNames():
            builder_status = self.status.getBuilder(bname)
            builder_control = None
            c = self.getControl(req)
            if c:
                builder_control = c.getBuilder(bname)
            (state, current_builds) = builder_status.getState()

            if state != "building" and state != "pending":
            elif state == "pending" :
            elif state == "building" :
                if len(builder_status.getPendingBuilds()) > 0:  # keep the
last pending one
                    for b in current_builds:
                        log.msg("!!!!   current build [ %s ] number [%s] to
stop " % (str(b), str(b.number)))
                        build_status = builder_status.getBuild(b.number)

                        if not build_status:
                        if builder_control:
                            build_control =
                            build_control = None
                        build = StatusResourceBuild(build_status,
                    pass  # no pending, just ignore stop instruction

        # go back to the welcome page
        return Redirect("../..")

in:  process.builder , class BuilderControl
    def cancelAllPendingsExceptLastOne(self):
        """test method, see if they are available to be called."""
        if len(self.original.buildable) > 0:
            for p in self.original.buildable[:-1]:
            self.original.buildable = self.original.buildable[-1:]
in: interface, class IBuilderControl
        def cancelAllPendingsExceptLastOne():
        """remove all pending build request"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20090916/34debf3e/attachment.html>

More information about the devel mailing list