~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/buildd/buildd-config.py

  • Committer: mbp at canonical
  • Date: 2011-11-20 23:37:23 UTC
  • mto: This revision was merged to the branch mainline in revision 14344.
  • Revision ID: mbp@canonical.com-20111120233723-370p96db2crru5tm
Delete canonical.buildd again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
#
3
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
4
 
# GNU Affero General Public License version 3 (see the file LICENSE).
5
 
 
6
 
import os
7
 
 
8
 
archtag = os.popen("dpkg --print-architecture").read().strip()
9
 
 
10
 
from optparse import OptionParser
11
 
 
12
 
parser = OptionParser()
13
 
parser.add_option("-n", "--name", dest="NAME",
14
 
                  help="the name for this buildd",
15
 
                  metavar="NAME",
16
 
                  default="default")
17
 
 
18
 
parser.add_option("-H", "--host", dest="BINDHOST",
19
 
                  help="the IP/host this buildd binds to",
20
 
                  metavar="HOSTNAME",
21
 
                  default="localhost")
22
 
 
23
 
parser.add_option("-p", "--port", dest="BINDPORT",
24
 
                  help="the port this buildd binds to",
25
 
                  metavar="PORT",
26
 
                  default="8221")
27
 
 
28
 
parser.add_option("-a", "--arch", dest="ARCHTAG",
29
 
                  help="the arch tag this buildd claims",
30
 
                  metavar="ARCHTAG",
31
 
                  default=archtag)
32
 
 
33
 
parser.add_option("-t", "--template", dest="TEMPLATE",
34
 
                  help="the template file to use",
35
 
                  metavar="FILE",
36
 
                  default="/usr/share/launchpad-buildd/template-buildd-slave.conf")
37
 
 
38
 
(options, args) = parser.parse_args()
39
 
 
40
 
template = open(options.TEMPLATE, "r").read()
41
 
 
42
 
replacements = {
43
 
    "@NAME@": options.NAME,
44
 
    "@BINDHOST@": options.BINDHOST,
45
 
    "@ARCHTAG@": options.ARCHTAG,
46
 
    "@BINDPORT@": options.BINDPORT,
47
 
    }
48
 
 
49
 
for replacement_key in replacements:
50
 
    template = template.replace(replacement_key,
51
 
                                replacements[replacement_key])
52
 
 
53
 
print template
54