SHOW:
|
|
- or go back to the newest paste.
1 | # | |
2 | # New subclass of ShellCommand which allows the slave to supply either a html or straight-text log file (or a combination). | |
3 | # Adds it as an HTML log if and only if the extension of the log file is html, otherwise adds as text. | |
4 | # I had this defined in my own configuration file, but perhaps it belongs in the same file as ShellCommand? (steps/shell.py) | |
5 | # | |
6 | ||
7 | class HTMLOutputShellCommand(ShellCommand): | |
8 | ||
9 | def setupLogfiles(self, cmd, logfiles): | |
10 | for logname,remotefilename in logfiles.items(): | |
11 | if self.lazylogfiles: | |
12 | # Ask RemoteCommand to watch a logfile, but only add | |
13 | # it when/if we see any data. | |
14 | # | |
15 | # The dummy default argument local_logname is a work-around for | |
16 | # Python name binding; default values are bound by value, but | |
17 | # captured variables in the body are bound by name. | |
18 | callback = lambda cmd_arg, local_logname=logname: self.addHTMLOrTextLog(local_logname) | |
19 | cmd.useLogDelayed(logname, callback, True) | |
20 | else: | |
21 | # tell the BuildStepStatus to add a LogFile | |
22 | newlog = self.addHTMLOrTextLog(logname, remotefilename) | |
23 | # and tell the RemoteCommand to feed it | |
24 | cmd.useLog(newlog, True) | |
25 | ||
26 | def addHTMLOrTextLog(self, logname): | |
27 | ||
28 | remotefilename = self.logfiles[logname] | |
29 | if ( remotefilename.lower().endswith( ".html" ) ): | |
30 | html = "" # addHTMLLog requires html arg, but in this case, the actual contents are being added from the slave later. | |
31 | newlog = self.addHTMLLog(logname, html) | |
32 | else: | |
33 | # tell the BuildStepStatus to add a LogFile | |
34 | newlog = self.addLog(logname) | |
35 | return newlog | |
36 | ||
37 | # | |
38 | # BuildStep.addHTMLLog needs to return the log that it creates. | |
39 | # | |
40 | ||
41 | 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 | |
42 | 752c752 | |
43 | < self.step_status.addHTMLLog(name, html) | |
44 | --- | |
45 | > loog = self.step_status.addHTMLLog(name, html) | |
46 | 753a754 | |
47 | > return loog | |
48 | ||
49 | # | |
50 | # Patch to add html support in ShellCommand. | |
51 | # | |
52 | ||
53 | 876,891c877,902 | |
54 | < def setupLogfiles(self, cmd, logfiles): | |
55 | < for logname,remotefilename in logfiles.items(): | |
56 | < if self.lazylogfiles: | |
57 | < # Ask RemoteCommand to watch a logfile, but only add | |
58 | < # it when/if we see any data. | |
59 | < # | |
60 | < # The dummy default argument local_logname is a work-around for | |
61 | < # Python name binding; default values are bound by value, but | |
62 | < # captured variables in the body are bound by name. | |
63 | < callback = lambda cmd_arg, local_logname=logname: self.addLog(local_logname) | |
64 | < cmd.useLogDelayed(logname, callback, True) | |
65 | < else: | |
66 | < # tell the BuildStepStatus to add a LogFile | |
67 | < newlog = self.addLog(logname) | |
68 | < # and tell the RemoteCommand to feed it | |
69 | < cmd.useLog(newlog, True) | |
70 | --- | |
71 | > def setupLogfiles(self, cmd, logfiles): | |
72 | > for logname,remotefilename in logfiles.items(): | |
73 | > if self.lazylogfiles: | |
74 | > # Ask RemoteCommand to watch a logfile, but only add | |
75 | > # it when/if we see any data. | |
76 | > # | |
77 | > # The dummy default argument local_logname is a work-around for | |
78 | > # Python name binding; default values are bound by value, but | |
79 | > # captured variables in the body are bound by name. | |
80 | > callback = lambda cmd_arg, local_logname=logname: self.addHTMLOrTextLog(local_logname) | |
81 | > cmd.useLogDelayed(logname, callback, True) | |
82 | > else: | |
83 | > # tell the BuildStepStatus to add a LogFile | |
84 | > newlog = self.addHTMLOrTextLog(logname, remotefilename) | |
85 | > # and tell the RemoteCommand to feed it | |
86 | > cmd.useLog(newlog, True) | |
87 | > | |
88 | > def addHTMLOrTextLog(self, logname): | |
89 | > remotefilename = self.logfiles[logname] | |
90 | > if ( remotefilename.lower().endswith( ".html" ) ): | |
91 | > html = "" # addHTMLLog requires html arg, but in this case, the actual contents are being added from the slave later. | |
92 | > newlog = self.addHTMLLog(logname, html) | |
93 | > else: | |
94 | > # tell the BuildStepStatus to add a LogFile | |
95 | > newlog = self.addLog(logname) | |
96 | > return newlog | |
97 | ||
98 | # | |
99 | # BuildStepStatus.addHTMLLog needs to return the log that it creates. | |
100 | # | |
101 | ||
102 | 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 | |
103 | 250a251 | |
104 | > return log | |
105 | ||
106 | # | |
107 | # HTMLLogFile needs to implement the ILogFile interface, which is also implemented by the LogFile class, but HTMLLogFile | |
108 | # does not derive from LogFile. Without these, I was getting a crash in RemoteCommand.remoteComplete when it called | |
109 | # addHeader on the HTMLLogFile, which did not implement addHeader. | |
110 | # | |
111 | # I don't actually want the stderr or header to appear in the HTML output which is viewable from the waterfall, which is | |
112 | # why I only implemented addStdout, and not addStderr or addHeader. | |
113 | # | |
114 | ||
115 | 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 | |
116 | 639c639 | |
117 | < implements(interfaces.IStatusLog) | |
118 | --- | |
119 | > implements(interfaces.IStatusLog, interfaces.ILogFile) | |
120 | 681a682,690 | |
121 | > | |
122 | > def addStdout(self, text): | |
123 | > self.html += text | |
124 | > pass | |
125 | > def addStderr(self, text): | |
126 | > pass | |
127 | > def addHeader(self, text): | |
128 | - | > return newlog |
128 | + | > pass |