broken logs after 9 upgrade

Greg MacDonald gmacdonald at
Fri Oct 16 19:55:37 UTC 2015

I sorted it out, looks like I was yielding when I shouldn't have in _processLine. One of these days I'll have to spend some time with twisted. Thx. :)


From: Greg MacDonald
Sent: Thursday, October 15, 2015 12:12 PM
To: 'users at'
Subject: broken logs after 9 upgrade

Hi Everyone,

So after I upgraded to 0.9.0b2, my custom ObservedShellCommand class broke. The logs show up blank. I added some test output but it just outputs a single zero character. Any ideas? I'm not sure where to start looking. Thx!


class _LogObserver(util.LogLineObserver):

    def __init__(self, warningPatterns=None, errorPatterns=None, failImmediately=True):

        self.step = None
        self.warningPatterns = [compile(i, IGNORECASE) for i in warningPatterns] if warningPatterns else []
        self.errorPatterns = [compile(i, IGNORECASE) for i in errorPatterns] if errorPatterns else []
        self.failImmediately = failImmediately
        self.warnings = []
        self.errors = []
        self._log = None

    def log(self):
        return self.step.observerLog

    def _processLine(self, line):
        if any([ for i in self.errorPatterns]):
            yield self.log.addStdout(unicode('Error: ' + line))
            if self.failImmediately:
                yield self.log.addStdout(u'Aborting step from observed errors.')
                # TODO: Interrupt step cleanly.
                raise buildstep.BuildStepFailed('Aborting step from observed errors.')
        elif any([ for i in self.warningPatterns]):
            yield self.log.addStdout(unicode('Warning: ' + line))

    def outLineReceived(self, line):

    def errLineReceived(self, line):

    def getResults(self):
        if len(self.errors) > 0:
            return FAILURE
        if len(self.warnings) > 0:
            return WARNINGS
        return None

class ObservedShellCommand(buildstep.ShellMixin, buildstep.BuildStep):
    """Detects errors and warnings in stdio of a shell command."""
    name = "observed_shell"

    def __init__(self, warningPatterns=None, errorPatterns=None, failImmediately=True, **kwargs):
        kwargs = self.setupShellMixin(kwargs)
        buildstep.BuildStep.__init__(self, **kwargs)
        self.observerLog = None
        self.logObserver = _LogObserver(warningPatterns, errorPatterns, failImmediately)
        self.cmd = None

    def run(self):
        self.observerLog = yield self.addLog('observer')
        self.addLogObserver('stdio', self.logObserver)

        yield self.observerLog.addStdout(u'Observation log output test.')

        cmd = yield self.makeRemoteShellCommand()
        self.cmd = cmd

        yield self.runCommand(cmd)
        if cmd.results() in [FAILURE, EXCEPTION]:
            results = cmd.results()
            observedResults = self.logObserver.getResults()
            results = observedResults if observedResults else cmd.results()

    def interrupt(self, reason):
        buildstep.BuildStep.interrupt(self, reason)

        if self.cmd:
            d = self.cmd.interrupt(reason)
            d.addErrback(log.err, 'while interrupting command')

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list