]>
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; */
104 font-family: Courier New;
132 text-decoration: bold;
135 color: black; text-decoration: none;
138 color: black; text-decoration: none;
141 <meta http-equiv="refresh" content="90; URL=%(script)s" />
145 <h1>IPFire Builder</h1>""" % self
.config
146 for i
in self
.config
["nightly_url"]:
148 <p><a href="%s" target="_blank">%s</a></p>""" % (i
, i
,)
154 print "\t\t</body>\n</html>"
159 <div id="content">"""
160 for builder
in self
.builders
:
166 def __init__(self
, builder
):
167 self
.builder
= builder
168 self
.points
= POINTS_UNKNOWN
170 def __cmp__(self
, other
):
171 if self
.points
> other
.points
:
173 elif self
.points
== other
.points
:
175 elif self
.points
< other
.points
:
179 return """<a href="#%(hostname)s">%(hostname)s</a>""" % { "hostname" : self
.builder
.hostname(), }
181 def open_bigbox(self
):
182 print """<a name="%s"></a><div class="box" style="%s">""" \
183 % (self
.builder
.hostname(), state2style
[self
.builder
.state()],)
185 def open_infobox(self
):
186 print """<div class="infobox">"""
188 def close_bigbox(self
):
191 close_infobox
= close_bigbox
194 print """<p class="boxheader">%(hostname)s <span>[%(uuid)s]</span></p>""" \
195 % { "hostname" : self
.builder
.hostname(),
196 "state" : self
.builder
.state(),
197 "uuid" : self
.builder
.uuid
, }
200 if self
.builder
.state() in [ "compiling", "error", ]:
202 <p class="package">%s</p>"""\
203 % self
.builder
.package()
206 print """<p>%s</p>""" \
207 % time
.ctime(float(self
.builder
.state
.time()))
210 print """<p class="desc">%s</p>""" \
211 % statedesc
[self
.builder
.state()]
214 print """<p>Average Build Duration: %s</p>""" \
215 % format_time(self
.builder
.duration
.get_avg())
216 if self
.builder
.state() == "compiling":
217 print """<p>ETA: %s</p>""" \
218 % self
.builder
.duration
.get_eta(self
.builder
.state
.time())
220 def distccinfo(self
):
221 state
= self
.builder
.distcc
.ping()
222 port
= self
.builder
.distcc()
226 print """<p class="%s">Distcc: %s</p>""" \
227 % (ping2class
[state
], port
,)
230 log
= self
.builder
.log()
232 print """<div class="log"><p>"""
235 print "%s<br />" % (i
.rstrip("\n"),)
236 print """</p></div>"""
239 print """<div class="footer"><p>system: %s - cpu: %s <br /> target: %s - jobs: %s - toolchain: %s</p></div>""" \
240 % (self
.builder
.system(), self
.builder
.cpu(), 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
)