Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # New subclass of ShellCommand which allows the slave to supply either a html or straight-text log file (or a combination).
- # Adds it as an HTML log if and only if the extension of the log file is html, otherwise adds as text.
- # I had this defined in my own configuration file, but perhaps it belongs in the same file as ShellCommand? (steps/shell.py)
- #
- class HTMLOutputShellCommand(ShellCommand):
- def setupLogfiles(self, cmd, logfiles):
- for logname,remotefilename in logfiles.items():
- if self.lazylogfiles:
- # Ask RemoteCommand to watch a logfile, but only add
- # it when/if we see any data.
- #
- # The dummy default argument local_logname is a work-around for
- # Python name binding; default values are bound by value, but
- # captured variables in the body are bound by name.
- callback = lambda cmd_arg, local_logname=logname: self.addHTMLOrTextLog(local_logname)
- cmd.useLogDelayed(logname, callback, True)
- else:
- # tell the BuildStepStatus to add a LogFile
- newlog = self.addHTMLOrTextLog(logname, remotefilename)
- # and tell the RemoteCommand to feed it
- cmd.useLog(newlog, True)
- def addHTMLOrTextLog(self, logname):
- remotefilename = self.logfiles[logname]
- if ( remotefilename.lower().endswith( ".html" ) ):
- html = "" # addHTMLLog requires html arg, but in this case, the actual contents are being added from the slave later.
- newlog = self.addHTMLLog(logname, html)
- else:
- # tell the BuildStepStatus to add a LogFile
- newlog = self.addLog(logname)
- return newlog
- #
- # BuildStep.addHTMLLog needs to return the log that it creates.
- #
- diff -r D:\buildbot\buildbot-0.8.8-original\buildbot/process/buildstep.py D:\buildbot\buildbot-0.8.8-py2.7.egg-HTMLHack\buildbot/process/buildstep.py
- 752c752
- < self.step_status.addHTMLLog(name, html)
- ---
- > loog = self.step_status.addHTMLLog(name, html)
- 753a754
- > return loog
- #
- # BuildStepStatus.addHTMLLog needs to return the log that it creates.
- #
- diff -r D:\buildbot\buildbot-0.8.8-original\buildbot/status/buildstep.py D:\buildbot\buildbot-0.8.8-py2.7.egg-HTMLHack\buildbot/status/buildstep.py
- 250a251
- > return log
- #
- # HTMLLogFile needs to implement the ILogFile interface, which is also implemented by the LogFile class, but HTMLLogFile
- # does not derive from LogFile. Without these, I was getting a crash in RemoteCommand.remoteComplete when it called
- # addHeader on the HTMLLogFile, which did not implement addHeader.
- #
- # I don't actually want the stderr or header to appear in the HTML output which is viewable from the waterfall, which is
- # why I only implemented addStdout, and not addStderr or addHeader.
- #
- diff -r D:\buildbot\buildbot-0.8.8-original\buildbot/status/logfile.py D:\buildbot\buildbot-0.8.8-py2.7.egg-HTMLHack\buildbot/status/logfile.py
- 639c639
- < implements(interfaces.IStatusLog)
- ---
- > implements(interfaces.IStatusLog, interfaces.ILogFile)
- 681a682,690
- >
- > def addStdout(self, text):
- > self.html += text
- > pass
- > def addStderr(self, text):
- > pass
- > def addHeader(self, text):
- > pass
- #
- # Patch to add html support in ShellCommand.
- #
- 876,891c877,902
- < def setupLogfiles(self, cmd, logfiles):
- < for logname,remotefilename in logfiles.items():
- < if self.lazylogfiles:
- < # Ask RemoteCommand to watch a logfile, but only add
- < # it when/if we see any data.
- < #
- < # The dummy default argument local_logname is a work-around for
- < # Python name binding; default values are bound by value, but
- < # captured variables in the body are bound by name.
- < callback = lambda cmd_arg, local_logname=logname: self.addLog(local_logname)
- < cmd.useLogDelayed(logname, callback, True)
- < else:
- < # tell the BuildStepStatus to add a LogFile
- < newlog = self.addLog(logname)
- < # and tell the RemoteCommand to feed it
- < cmd.useLog(newlog, True)
- ---
- > def setupLogfiles(self, cmd, logfiles):
- > for logname,remotefilename in logfiles.items():
- > if self.lazylogfiles:
- > # Ask RemoteCommand to watch a logfile, but only add
- > # it when/if we see any data.
- > #
- > # The dummy default argument local_logname is a work-around for
- > # Python name binding; default values are bound by value, but
- > # captured variables in the body are bound by name.
- > callback = lambda cmd_arg, local_logname=logname: self.addHTMLOrTextLog(local_logname)
- > cmd.useLogDelayed(logname, callback, True)
- > else:
- > # tell the BuildStepStatus to add a LogFile
- > newlog = self.addHTMLOrTextLog(logname, remotefilename)
- > # and tell the RemoteCommand to feed it
- > cmd.useLog(newlog, True)
- >
- > def addHTMLOrTextLog(self, logname):
- > remotefilename = self.logfiles[logname]
- > if ( remotefilename.lower().endswith( ".html" ) ):
- > html = "" # addHTMLLog requires html arg, but in this case, the actual contents are being added from the slave later.
- > newlog = self.addHTMLLog(logname, html)
- > else:
- > # tell the BuildStepStatus to add a LogFile
- > newlog = self.addLog(logname)
- > return newlog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement