annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """(re)start the buildbot"""
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
282
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
5 import optparse
36
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 import os
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 import sys
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 from subprocess import call
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 from time import sleep
d91d3dfadb6b stub for restarting the bot
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
282
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
11 here = os.path.abspath(os.path.dirname(sys.argv[0]))
187
bba97450cbc2 * update example and templates
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
12 debug = {{debug}}
282
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
13
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
14 def main(args=sys.argv[1:]):
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
15
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
16 # parse command line options
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
17 usage = '%prog [options]'
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
18 parser = optparse.OptionParser(usage=usage, description=__doc__)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
19 parser.add_option('--stop', dest='stop',
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
20 action='store_true', default=False,
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
21 help="stop the buildbot only")
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
22 # could force a build here
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
23 # buildbot sendchange ...
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
24 options, args = parser.parse_args(args)
187
bba97450cbc2 * update example and templates
Jeff Hammel <jhammel@mozilla.com>
parents: 54
diff changeset
25
282
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
26 # cleanup
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
27 if debug:
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
28 call(['rm', '-f', 'master/twistd.log'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
29 call(['rm', '-f', 'slave/twistd.log'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
30 call(['rm', '-rf', 'slave/full'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
31
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
32 # stop running instance
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
33 call(['buildbot', 'stop', 'master'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
34 call(['buildslave', 'stop', 'slave'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
35
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
36 # start new instance
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
37 if not options.stop:
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
38 call(['buildbot', 'start', 'master'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
39 call(['buildslave', 'start', 'slave'], cwd=here)
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
40
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
41
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
42 if __name__ == '__main__':
2cda5a640ae7 make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents: 187
diff changeset
43 main()