]>
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
):
54 response
= Response(config
)
56 data
= cgi
.FieldStorage()
58 uuid
= data
.getfirst("uuid")
59 action
= data
.getvalue('action')
62 response
.set_code("406")
63 response
.set_mesg("UUID is not valid!")
66 builder
= Builder(config
, uuid
)
69 for key
in [ "distcc", "duration", "hostname", "jobs", "log", "state", "package", "target" ]:
70 for value
in data
.getlist(key
):
71 builder
.set(key
, value
)
73 for key
in [ "distcc", ]:
75 for value
in data
.getlist(key
):
79 for builder
in getAllBuilders():
80 if uuid
== builder
.uuid
:
83 builders
.append("%s" % builder
.distcc
)
84 string
= "localhost/%s\n--randomize\n" % (jobs
or "4",)
86 if not builders
: break
87 rand
= random
.randint(0, len(builders
)-1)
89 string
= "%s%s\n" % (string
, builders
[rand
],)
91 response
.set_mesg(string
)
94 response
.set_code("501")
95 response
.set_mesg("Don't know what to do with command \"%s\"" % action
)