[Buildbot-devel] Dynamically updating text displayed in build step status

Neal Norwitz nnorwitz at gmail.com
Wed Apr 19 04:34:08 UTC 2006


On 4/18/06, Brian Warner <warner-buildbot at lothar.com> wrote:
>
>     def getText(self, cmd, results):
>         text = self.describe(True)
>         if results == WARNINGS:
>             text = text + ["warnings"]
>         if results == FAILURE:
>             text = text + ["failed"]
>         if self.version:
>             text = text + ["version=" + self.version]
>         return text
>
> Each one of those 'text = text + []' statements will create a brand-new list,
> so the original description is left unmodified.

You can just copy the list the first time, then append (it seems if
the only reqt is that the list not be the original).  This should be
more efficient (only allocates a list one time, then resizes if
necessary) in case it matters:

>     def getText(self, cmd, results):
  # assume self.describe() returns a list and copy it
>         text = self.describe(True)[:]
>         if results == WARNINGS:
>             text.append("warnings")
>         if results == FAILURE:
>             text.append("failed")
>         if self.version:
>             text.append("version=" + self.version)
>         return text

n




More information about the devel mailing list