[Buildbot-devel] Re: Dynamically updating text displayed in build step status
Grig Gheorghiu
grig at gheorghiu.net
Thu Mar 30 22:26:12 UTC 2006
One more question:
Here's a fragment of code from my master.cfg file:
c['builders'] = []
for client_bot in client_bots:
client_name = client_bot[0]
client_type = client_types[client_name]
client_uninstall_step = s(ClientUninstall, command="python
client_uninstall.py", timeout=3600)
client_install_step = s(ClientInstall, command="python
client_install.py", timeout=3600)
client_smoke_test_step = s(ClientSmokeTests, command="python
run_smoke_tests.py", timeout=3600)
client_test_factory = factory.BuildFactory([
client_uninstall_step,
client_install_step,
client_smoke_test_step,
])
builder = {
'name': client_type,
'slavename': client_name,
'builddir': client_type.lower(),
'factory': client_test_factory,
}
c['builders'].append(builder)
All the different classes specified in the step object definition
(ClientInstall, ClientUninstall, etc.) are derived from ShellCommand.
The ClientInstall class is the one I described in my original message
(see below).
Although I instantiate new step objects and factory objects for each of
the builders, my suspicion is that a single step instance is shared
among all the builders. I say this because if I leave this code in
ClientInstall.getText:
def getText(self, cmd, results):
text = self.describe(True)
if results == WARNINGS:
text += ["warnings"]
if results == FAILURE:
text += ["failed"]
if self.version:
text += ["version=" + self.version]
return text
then the text "version=x.y.z" gets printed multiple times in each of
the ClientInstall status boxes, once for each of the builders. I end up
with something like this in every box:
client install
version=3.5.0.371
version=3.5.0.371
version=3.5.0.371
version=3.5.0.371
version=3.5.0.371
version=3.5.0.367
version=3.5.0.371
version=3.5.0.371
Is there a way I can make sure that each builder has its own instance
of the ClientInstall class, so that they don't trample on each other?
Again, I might be missing something here in terms of my understanding
of how everything works together, so I'd appreciate if anybody could
shed some light.
Grig
--- Grig Gheorghiu <grig at gheorghiu.net> wrote:
> Hi,
>
> I've been trying to find ways to dynamically update the text that is
> displayed in the build step status in the HTML Waterfall page.
>
> For static customization of the text, I just subclassed from
> ShellCommand and I set 'descriptionDone' to my custom text.
>
> However, I also wanted to be able to display a piece of information
> (such as a version number) that was computed by the slave running
> that
> build step. I looked through the mailing list, but I couldn't find
> something that covered my exact situation, so I came up with the
> following:
>
> Assume there's a build step where the slave installs some package and
> identifies its version number. I want to be able to display that
> version number in the status for that build step.
>
> I defined the following subclass of ShellCommand:
>
> class ClientInstall(ShellCommand):
> name = "client install"
> description = ["running %s" % name]
> descriptionDone = [name]
>
> def __init__(self, **kwargs):
> ShellCommand.__init__(self, **kwargs)
> self.version = None
>
> def createSummary(self, log):
> log_text = log.getText()
> s = re.search("--version=(.*)", log_text)
> if s:
> self.version = s.group(1)
>
> def getText(self, cmd, results):
> text = self.describe(True)
> for elem in text:
> if re.search("version", elem):
> return text
> if results == WARNINGS:
> text += ["warnings"]
> if results == FAILURE:
> text += ["failed"]
> if self.version:
> text += ["version=" + self.version]
> return text
>
>
> I'm retrieving the version number via a regular expression match from
> the slave's log file. Then I'm appending this version to the list
> returned by getText.
>
> Note that I had to add this condition inside getText:
>
> for elem in text:
> if re.search("version", elem):
> return text
>
> otherwise the my custom addition would appear several times in the
> status text (which means that getText got called repeatedly).
>
> I'm using my custom ClientInstall class as one of the steps defined
> in
> master.cfg.
>
> Question: am I on the right track here, or am I needlessly
> complicating
> my life?
>
> Thanks,
>
> Grig Gheorghiu
>
More information about the devel
mailing list