]>
git.ipfire.org Git - ipfire.org.git/blob - build/distcc.py
3 import cgitb
, os
, time
, cgi
, re
, random
, socket
, DNS
6 def print_http_header():
7 print "Content-type: text/html"
12 print '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
13 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
16 <title>IPFire - DistccWatch</title>
17 <style type="text/css">
18 body { font-family: Verdana; font-size: 9pt; background-color:#f0f0f0; }
19 a:link { color: black; text-decoration: none; }
20 a:visited { color: black; text-decoration: none; }
21 table { font-family: Verdana; font-size: 8pt; border: 1px solid; }
22 td.header { background-color: #a0a0a0; text-align: center; color: white; }
23 td.date { text-align: center; }
24 font.installed { color: green; }
25 font.deleted { color: red; }
26 font.update { color: blue; }
27 font.error { color: red; }
28 td.online { background: green; color: white; text-align: center; }
29 td.offline { background: red; color: white; text-align: center; }
31 <meta http-equiv="refresh" content="60; URL=%s" />
34 <h1>IPFire DistccWatch</h1>
35 <p>Made: %s</p>''' % (os
.environ
['SCRIPT_NAME'], time
.ctime())
38 print "\t</body>\n</html>"
42 print os
.popen("distcc --version").read(),
55 if not line
.startswith("#"):
56 hosts
.append(line
.rstrip("\n"))
58 def process_hosts(hosts
=""):
60 print "You need to specify the hosts you want to check in the config file."
63 print '''<table width='66%'>
65 <td class='header' width='68%'>Host</td>
66 <td class='header' width='16%'>State</td>
67 <td class='header' width='16%'>Probe</td>
70 for hostname
in hosts
:
74 command
= "HOME=tmp DISTCC_HOSTS=\"%s\" DISTCC_VERBOSE=1 distcc probe.c -S -o /dev/null 2>&1" % hostname
75 state_pattern
= re
.compile("on %s completed ok" % hostname
)
76 time_pattern
= re
.compile("elapsed compilation time ")
78 for line
in os
.popen(command
).readlines():
79 state_result
= re
.search(state_pattern
, line
)
80 time_result
= re
.search(time_pattern
, line
)
81 if not state_result
== None:
83 if not time_result
== None:
85 time
= time_result
.string
[-10:]
87 print "<tr><td><pre>%s</pre></td><td>%s</td><td>%s</td></tr>" % (hostname
, state
, time
)
91 def mixup_hosts(hosts
=""):
97 rand
= random
.randint(0, len(hosts
)-1)
98 host
, options
= re
.split(re
.compile(':'),hosts
[rand
])
99 string
+= socket
.gethostbyname(host
) + ":" + options
+ " "
104 form
= cgi
.FieldStorage()
105 action
= form
.getfirst('action')