]>
Commit | Line | Data |
---|---|---|
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 | ||
22 | import os | |
23 | import sys | |
24 | import cgi | |
2b60fce9 MT |
25 | |
26 | sys.path.append(".") | |
27 | ||
28 | from builder import Builder, getAllBuilders | |
29 | from constants import config | |
30 | ||
18f33403 MT |
31 | ALLOWED_ACTIONS_SET = ( "distcc", "duration", "hostname", "jobs", "log", "state", |
32 | "package", "target", "toolchain", "cpu", "machine",) | |
33 | ALLOWED_ACTIONS_GET = ( "distcc",) | |
2b60fce9 | 34 | |
18f33403 MT |
35 | def 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: | |
48 | print "localhost/%s" % (builder.jobs() or "4") | |
49 | else: | |
eeaf3c5c MT |
50 | if ((myself.toolchain() == builder.toolchain()) and \ |
51 | (myself.target() == builder.target())): | |
18f33403 | 52 | print "%s" % (builder.distcc,) |
2b60fce9 | 53 | |
18f33403 MT |
54 | elif action == "set": |
55 | for key in ALLOWED_ACTIONS_SET: | |
2b60fce9 | 56 | for value in data.getlist(key): |
18f33403 MT |
57 | print myself.set(key, value) |
58 | ||
59 | data = cgi.FieldStorage() | |
60 | ||
61 | print "Status: 200 - OK" # We always send okay. | |
62 | ||
2b60fce9 | 63 | |
18f33403 MT |
64 | try: |
65 | uuid = data.getfirst("uuid") | |
66 | action = data.getfirst("action") | |
67 | if uuid and action: | |
68 | run(uuid, action) | |
69 | except SystemExit: | |
70 | pass |