]> git.ipfire.org Git - ipfire.org.git/blame - build/rpc.py
Redirect to http-source of the ftp-server for nightly builds.
[ipfire.org.git] / build / rpc.py
CommitLineData
2b60fce9
MT
1#!/usr/bin/python
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
18f33403 5# Copyright (C) 2008,2009 Michael Tremer & Christian Schmidt #
2b60fce9
MT
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
21
22import os
23import sys
24import cgi
2b60fce9
MT
25
26sys.path.append(".")
27
28from builder import Builder, getAllBuilders
29from constants import config
30
18f33403 31ALLOWED_ACTIONS_SET = ( "distcc", "duration", "hostname", "jobs", "log", "state",
29d9e336 32 "package", "target", "toolchain", "cpu", "machine", "system",)
18f33403 33ALLOWED_ACTIONS_GET = ( "distcc",)
2b60fce9 34
18f33403
MT
35def run(uuid, action):
36 myself = Builder(config, uuid)
2b60fce9 37
18f33403
MT
38 if action == "get":
39 for key in ALLOWED_ACTIONS_GET:
40 if key == "distcc":
41 for value in data.getlist(key):
42 if value == "raw":
43 builders = getAllBuilders()
44 print "--randomize"
45 for builder in builders:
46 # Print "localhost" for ourself
47 if myself.uuid == builder.uuid:
29d9e336 48 print "localhost"
18f33403 49 else:
eeaf3c5c 50 if ((myself.toolchain() == builder.toolchain()) and \
51ebdbee 51 (myself.machine() == builder.machine()) and \
eeaf3c5c 52 (myself.target() == builder.target())):
18f33403 53 print "%s" % (builder.distcc,)
2b60fce9 54
18f33403
MT
55 elif action == "set":
56 for key in ALLOWED_ACTIONS_SET:
2b60fce9 57 for value in data.getlist(key):
18f33403
MT
58 print myself.set(key, value)
59
60data = cgi.FieldStorage()
61
62print "Status: 200 - OK" # We always send okay.
63print
2b60fce9 64
18f33403
MT
65try:
66 uuid = data.getfirst("uuid")
67 action = data.getfirst("action")
68 if uuid and action:
69 run(uuid, action)
70except SystemExit:
71 pass