[clug] Help with a python regexp?

Brad Hards bradh at frogmouth.net
Fri Feb 20 10:08:39 GMT 2009


Hi,

I've been playing with buildbot (http://buildbot.net:80/trac), and I've run 
into a problem. 

A bit of background first. One of the thing that happens with the compile step 
is that it extracts the warnings messages from the rest of stdout.
So given this:
http://colo1.frogmouth.net:8010/builders/full-centos52/builds/109/steps/compile/logs/stdio
it pulls out:
http://colo1.frogmouth.net:8010/builders/full-centos52/builds/109/steps/compile/logs/warnings

The method to do that looks like this:

    def createSummary(self, log):
        self.warnCount = 0

        if not self.warningPattern:
            return

        wre = self.warningPattern
        if isinstance(wre, str):
            wre = re.compile(wre)

        # Check if each line in the output from this command matched our
        # warnings regular expressions. If did, bump the warnings count and
        # add the line to the collection of lines with warnings
        warnings = []
        for line in log.getText().split("\n"):
            if wre.match(line):
                warnings.append(line)
                self.warnCount += 1

The warningPattern is (by default) is
    warningPattern = '.*warning[: ].*'

The problem is that I can't fix some of the warnings. Basically, all those 
lines that start with "exchange.idl" are hiding the real compile warnings.

I don't want to hide the lines in a normal build (e.g. by piping 
to /dev/null), only filtering on the buildbot. Hacking the method is a 
possibility, but I'd prefer to just have a better regexp.

So how to I match a line containing "warning:", as long as it doesn't start 
with "exchange.idl"?

All help much appreciated

Brad


More information about the linux mailing list