]>
git.ipfire.org Git - ipfire.org.git/blob - build/rpc.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 ###############################################################################
30 from builder
import Builder
, getAllBuilders
31 from constants
import config
34 def __init__(self
, config
):
40 def __call__(self
, exit
=0):
41 print "Status: %s" % self
.code
42 print "Content-type: text/plain"
44 print "%s" % self
.mesg
48 def set_code(self
, code
):
51 def set_mesg(self
, mesg
):
57 self
.mesg
+= "[%s] - %s" % (time
.ctime(), s
,)
59 response
= Response(config
)
61 data
= cgi
.FieldStorage()
63 uuid
= data
.getfirst("uuid")
64 action
= data
.getvalue('action')
67 response
.set_code("406")
68 response
.set_mesg("UUID is not valid!")
71 builder
= Builder(config
, uuid
)
74 for key
in [ "distcc", "duration", "hostname", "jobs", "log", "state", "package", "target", "cpu", "machine" ]:
75 for value
in data
.getlist(key
):
76 ret
= builder
.set(key
, value
)
80 for key
in [ "distcc", ]:
82 for value
in data
.getlist(key
):
86 for builder
in getAllBuilders():
87 if uuid
== builder
.uuid
:
90 builders
.append("%s" % builder
.distcc
)
91 string
= "localhost/%s\n--randomize\n" % (jobs
or "4",)
93 if not builders
: break
94 rand
= random
.randint(0, len(builders
)-1)
96 string
= "%s%s\n" % (string
, builders
[rand
],)
98 response
.set_mesg(string
)
101 response
.set_code("501")
102 response
.set_mesg("Don't know what to do with command \"%s\"" % action
)