]>
git.ipfire.org Git - ipfire.org.git/blob - build/index.py
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
28 from builder
import Builder
, getAllBuilders
29 from constants
import *
31 def format_time(seconds
, use_hours
=1):
32 if seconds
is None or seconds
< 0:
33 if use_hours
: return '--:--:--'
36 seconds
= int(seconds
)
37 minutes
= seconds
/ 60
38 seconds
= seconds
% 60
41 minutes
= minutes
% 60
42 return '%02i:%02i:%02i' % (hours
, minutes
, seconds
)
44 return '%02i:%02i' % (minutes
, seconds
)
47 def __init__(self
, config
):
50 print "Content-type: text/html"
53 def __call__(self
, builders
=None):
54 self
.builders
= builders
55 print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
56 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
57 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
59 <title>%(title)s</title>
60 <style type="text/css">
64 text-decoration: none;
70 background-color:#f9f9f9;
73 text-decoration: underline;
79 border: 1px solid #999;
89 margin: 10px 0 10px 0;
101 /* visibility: hidden; */
106 font-family: Courier New;
134 text-decoration: bold;
137 color: black; text-decoration: none;
140 color: black; text-decoration: none;
143 <meta http-equiv="refresh" content="90; URL=%(script)s" />
147 <h1>IPFire Builder</h1>""" % self
.config
148 for i
in self
.config
["nightly_url"]:
150 <p><a href="%s" target="_blank">%s</a></p>""" % (i
, i
,)
156 print "\t\t</body>\n</html>"
161 <div id="content">"""
162 for builder
in self
.builders
:
168 def __init__(self
, builder
):
169 self
.builder
= builder
170 self
.points
= POINTS_UNKNOWN
172 def __cmp__(self
, other
):
173 if self
.points
> other
.points
:
175 elif self
.points
== other
.points
:
177 elif self
.points
< other
.points
:
181 return """<a href="#%(hostname)s">%(hostname)s</a>""" % { "hostname" : self
.builder
.hostname(), }
183 def open_bigbox(self
):
184 print """<a name="%s"></a><div class="box" style="%s">""" \
185 % (self
.builder
.hostname(), state2style
[self
.builder
.state()],)
187 def open_infobox(self
):
188 print """<div class="infobox">"""
190 def close_bigbox(self
):
193 close_infobox
= close_bigbox
196 print """<p class="boxheader">%(hostname)s <span>[%(uuid)s]</span></p>""" \
197 % { "hostname" : self
.builder
.hostname(),
198 "state" : self
.builder
.state(),
199 "uuid" : self
.builder
.uuid
, }
202 if self
.builder
.state() in [ "compiling", "error", ]:
204 <p class="package">%s</p>"""\
205 % self
.builder
.package()
208 print """<p>%s</p>""" \
209 % time
.ctime(float(self
.builder
.state
.time()))
212 print """<p class="desc">%s</p>""" \
213 % statedesc
[self
.builder
.state()]
216 print """<p>Average Build Duration: %s</p>""" \
217 % format_time(self
.builder
.duration
.get_avg())
218 if self
.builder
.state() == "compiling":
219 print """<p>ETA: %s</p>""" \
220 % self
.builder
.duration
.get_eta(self
.builder
.state
.time())
222 def distccinfo(self
):
223 state
= self
.builder
.distcc
.ping()
224 port
= self
.builder
.distcc()
228 print """<p class="%s">Distcc: %s</p>""" \
229 % (ping2class
[state
], port
,)
232 log
= self
.builder
.log()
234 print """<div class="log"><p>"""
235 print "<br />".join(log
)
236 print """</p></div>"""
239 print """<div class="footer"><p>system: %s - cpu: %s <br /> machine: %s - target: %s - jobs: %s - toolchain: %s</p></div>""" \
240 % (self
.builder
.system(), self
.builder
.cpu(), self
.builder
.machine(), self
.builder
.target(), self
.builder
.jobs(), self
.builder
.toolchain(),)
242 class BoxCompiling(Box
):
243 def __init__(self
, builder
):
244 Box
.__init
__(self
, builder
)
245 self
.points
= POINTS_COMPILING
261 def __init__(self
, builder
):
262 Box
.__init
__(self
, builder
)
263 self
.points
= POINTS_ERROR
279 class BoxDistcc(Box
):
280 def __init__(self
, builder
):
281 Box
.__init
__(self
, builder
)
282 self
.points
= POINTS_DISTCC
297 def __init__(self
, builder
):
298 Box
.__init
__(self
, builder
)
299 self
.points
= POINTS_IDLE
316 for builder
in getAllBuilders():
318 if builder
.state() == "compiling":
319 box
= BoxCompiling(builder
)
320 elif builder
.state() == "error":
321 box
= BoxError(builder
)
322 elif builder
.state() == "idle":
323 box
= BoxIdle(builder
)
324 elif builder
.state() == "distcc":
325 if builder
.distcc() == "0":
327 box
= BoxDistcc(builder
)