comparison autobot/template/restart_buildbot.py @ 282:2cda5a640ae7

make this more of a script and add a --stop option
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 01 Aug 2012 14:00:55 -0700
parents bba97450cbc2
children aec0a7f8c191
comparison
equal deleted inserted replaced
281:6ac4cfa28465 282:2cda5a640ae7
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 """(re)start the buildbot""" 3 """(re)start the buildbot"""
4 4
5 import optparse
5 import os 6 import os
6 import sys 7 import sys
7 from subprocess import call 8 from subprocess import call
8 from time import sleep 9 from time import sleep
9 10
10 os.chdir(os.path.abspath(os.path.dirname(sys.argv[0]))) 11 here = os.path.abspath(os.path.dirname(sys.argv[0]))
12 debug = {{debug}}
11 13
12 debug = {{debug}} 14 def main(args=sys.argv[1:]):
13 if debug:
14 call(['rm', '-f', 'master/twistd.log'])
15 call(['rm', '-f', 'slave/twistd.log'])
16 call(['rm', '-rf', 'slave/full'])
17 call(['buildbot', 'stop', 'master'])
18 call(['buildslave', 'stop', 'slave'])
19 call(['buildbot', 'start', 'master'])
20 call(['buildslave', 'start', 'slave'])
21 15
22 # could force a build here 16 # parse command line options
23 # buildbot sendchange ... 17 usage = '%prog [options]'
18 parser = optparse.OptionParser(usage=usage, description=__doc__)
19 parser.add_option('--stop', dest='stop',
20 action='store_true', default=False,
21 help="stop the buildbot only")
22 # could force a build here
23 # buildbot sendchange ...
24 options, args = parser.parse_args(args)
25
26 # cleanup
27 if debug:
28 call(['rm', '-f', 'master/twistd.log'], cwd=here)
29 call(['rm', '-f', 'slave/twistd.log'], cwd=here)
30 call(['rm', '-rf', 'slave/full'], cwd=here)
31
32 # stop running instance
33 call(['buildbot', 'stop', 'master'], cwd=here)
34 call(['buildslave', 'stop', 'slave'], cwd=here)
35
36 # start new instance
37 if not options.stop:
38 call(['buildbot', 'start', 'master'], cwd=here)
39 call(['buildslave', 'start', 'slave'], cwd=here)
40
41
42 if __name__ == '__main__':
43 main()