broken logs after 9 upgrade

Dustin J. Mitchell dustin at v.igoro.us
Sun Oct 18 16:17:17 UTC 2015


That's one of the downsides of generator-based async programming: if
you accidentally put a yield in a non-decorated function, it just
quietly does nothing.  Worth noting that ES6's "async" syntax still
has some of these issues, too.

Dustin

On Fri, Oct 16, 2015 at 3:55 PM, Greg MacDonald
<gmacdonald at trionworlds.com> wrote:
> 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. J
>
>
>
> -Greg
>
>
>
>
>
> From: Greg MacDonald
> Sent: Thursday, October 15, 2015 12:12 PM
> To: 'users at buildbot.net'
> 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!
>
>
>
> -Greg
>
>
>
> class _LogObserver(util.LogLineObserver):
>
>
>
>     def __init__(self, warningPatterns=None, errorPatterns=None,
> failImmediately=True):
>
>         util.LogLineObserver.__init__(self)
>
>
>
>         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
>
>
>
>     @property
>
>     def log(self):
>
>         return self.step.observerLog
>
>
>
>     def _processLine(self, line):
>
>         if any([i.search(line) for i in self.errorPatterns]):
>
>             self.errors.append(line)
>
>             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([i.search(line) for i in self.warningPatterns]):
>
>             self.warnings.append(line)
>
>             yield self.log.addStdout(unicode('Warning: ' + line))
>
>
>
>     def outLineReceived(self, line):
>
>         self._processLine(line)
>
>
>
>     def errLineReceived(self, line):
>
>         self._processLine(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
>
>
>
>     @defer.inlineCallbacks
>
>     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()
>
>         else:
>
>             observedResults = self.logObserver.getResults()
>
>             results = observedResults if observedResults else cmd.results()
>
>         defer.returnValue(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')
>
>
>
>
> _______________________________________________
> users mailing list
> users at buildbot.net
> https://lists.buildbot.net/mailman/listinfo/users


More information about the users mailing list