annotate autobot/template.py @ 37:b41f50162908

add a debug variable
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 08 Jan 2011 11:06:57 -0800
parents fdddf883c19d
children 42ef457708de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
3
1d615610e442 add a docstring
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
4 templates for the A*Team's buildbot
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
12
848569b7f91a use subdirectories for the master and slave
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
7 import os
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import sys
6
4ba6ba323871 stub out invocation of the template; this should eventually move to its own class, as we will want to subclass MakeItSoCLI, /me thinks
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
9 from makeitso.cli import MakeItSoCLI
23
a32a7055f3e6 combine variables for buildbot master+slave
Jeff Hammel <jhammel@mozilla.com>
parents: 22
diff changeset
10 from makeitso.template import assemble
4
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
11 from makeitso.template import MakeItSoTemplate
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
12 from makeitso.template import Variable
16
9ad3a9e220bc get factory from command line
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
13 from projects import factories
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
17
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
15 try:
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
16 from subprocess import check_call as call
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
17 except ImportError:
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
18 from subprocess import call
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
19
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 class AutobotMasterTemplate(MakeItSoTemplate):
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 name = 'autobot-master'
4
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
22 description = 'template for the autotools buildbot master'
12
848569b7f91a use subdirectories for the master and slave
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
23 templates = [os.path.join('template', 'master')]
4
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
24 vars = [Variable('slave', 'buildslave name', 'slave'),
5
b7c521f53bda document what the passwd variable is for
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
25 Variable('passwd', 'buildslave password', default='passwd'),
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
26 Variable('slaveport', 'port to talk to slaves on', default=9010, cast=int),
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
27 Variable('htmlport', 'port for waterfall display', default=8010, cast=int)]
4
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
28
9
c06441767a2a now interpolates correctly; just doesnt do much
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
29 def pre(self, variables):
16
9ad3a9e220bc get factory from command line
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
30 factory = variables.get('factory')
13
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
31 if factory:
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
32 assert factory in factories, 'Factory must be one of: ' % ', '.join(factories.keys())
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
33 elif self.interactive:
16
9ad3a9e220bc get factory from command line
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
34 print 'Factories:\n'
13
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
35 for key in sorted(factories.keys()):
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
36 print '%s:' % key
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
37 print getattr(factories[key], '__doc__', '').strip()
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
38 print
16
9ad3a9e220bc get factory from command line
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
39 sys.stdout.write('Enter factory: ')
13
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
40 factory = raw_input()
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
41 assert factory in factories, 'Factory must be one of: ' % ', '.join(factories.keys())
16
9ad3a9e220bc get factory from command line
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
42 variables['factory'] = factory
13
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
43 else:
59cc21718ced select factory
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
44 raise AssertionError("No factory provided")
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
45
25
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
46 def create(self, output, variables):
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
47 command = ['buildbot', 'create-master', output]
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
48 print ' '.join(command)
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
49 call(command)
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
50
18
016ffd7bfd99 can now actually make a (admittedly non-working) buildmaster
Jeff Hammel <jhammel@mozilla.com>
parents: 17
diff changeset
51 def post(self, variables):
17
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
52 """
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
53 called after the template is applied
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
54 """
26
fdddf883c19d first successful run of create-autobot script
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
55 self.create(self.output, variables)
17
baee795ad6df stub out actually calling buildbot
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
56
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
57 class AutobotSlaveTemplate(MakeItSoTemplate):
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
58 name = 'autobot-slave'
4
eb289a46f4d3 make buildbot master template look close to what it should
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
59 description = 'template for the autotools buildbot slave'
12
848569b7f91a use subdirectories for the master and slave
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
60 templates = [os.path.join('template', 'slave')]
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
61 vars = [Variable('master', 'host of the master', default='localhost'),
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
62 Variable('slave', 'buildslave name', 'slave'),
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
63 Variable('passwd', 'buildslave password', default='passwd'),
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
64 Variable('slaveport', 'port to talk to slaves on', default=9010)]
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
65
25
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
66 def create(self, output, variables):
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
67 command = ['buildslave', 'create-slave', output,
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
68 '%s:%d' % (variables['master'], variables['slaveport']),
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
69 variables['slave'],
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
70 variables['passwd'] ]
21
6c3c6488e4a9 can has a slave now
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
71 print ' '.join(command)
6c3c6488e4a9 can has a slave now
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
72 call(command)
25
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
73
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
74
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
75 def post(self, variables):
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
76 self.create(self.output, variables)
785b075be979 post method should work now [untested]
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
77
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
78
23
a32a7055f3e6 combine variables for buildbot master+slave
Jeff Hammel <jhammel@mozilla.com>
parents: 22
diff changeset
79 class AutobotTemplate(AutobotMasterTemplate, AutobotSlaveTemplate):
22
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
80 name = 'autobot'
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
81 description = 'template for the autotools buildbot master+slave'
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
82 templates = ['template']
23
a32a7055f3e6 combine variables for buildbot master+slave
Jeff Hammel <jhammel@mozilla.com>
parents: 22
diff changeset
83 vars = assemble(AutobotMasterTemplate, AutobotSlaveTemplate)
37
b41f50162908 add a debug variable
Jeff Hammel <jhammel@mozilla.com>
parents: 26
diff changeset
84 vars.append(Variable('debug', default=True, cast='eval'))
22
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
85
24
fe1bb4c667bc stub post method
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
86 def post(self, variables):
26
fdddf883c19d first successful run of create-autobot script
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
87 AutobotMasterTemplate.create(self, os.path.join(self.output, 'master'), variables)
fdddf883c19d first successful run of create-autobot script
Jeff Hammel <jhammel@mozilla.com>
parents: 25
diff changeset
88 AutobotSlaveTemplate.create(self, os.path.join(self.output, 'slave'), variables)
24
fe1bb4c667bc stub post method
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
89
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
90 # CLI front end functions
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
91 # (console_script entry points)
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
92
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
93 def create_master(args=sys.argv[1:]):
6
4ba6ba323871 stub out invocation of the template; this should eventually move to its own class, as we will want to subclass MakeItSoCLI, /me thinks
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
94 cli = MakeItSoCLI(AutobotMasterTemplate)
4ba6ba323871 stub out invocation of the template; this should eventually move to its own class, as we will want to subclass MakeItSoCLI, /me thinks
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
95 template = cli.parse()
8
6cba2df39955 time to substitute!
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
96 template.substitute()
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
97
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
98 def create_slave(args=sys.argv[1:]):
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
99 cli = MakeItSoCLI(AutobotSlaveTemplate)
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
100 template = cli.parse()
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
101 template.substitute()
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
102
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
103 def create_autobot(args=sys.argv[1:]):
23
a32a7055f3e6 combine variables for buildbot master+slave
Jeff Hammel <jhammel@mozilla.com>
parents: 22
diff changeset
104 cli = MakeItSoCLI(AutobotTemplate)
22
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
105 template = cli.parse()
a7e2f5b2a7e9 stub out a combined template for the master + slave
Jeff Hammel <jhammel@mozilla.com>
parents: 21
diff changeset
106 template.substitute()
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
107
1
3bd7f767d74a more stubbing of template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
108 if __name__ == '__main__':
20
30ec24255ce9 stub out having a slave template too
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
109 create_master()