Mercurial > hg > autobot
annotate autobot/template/restart_buildbot.py @ 301:aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 11 May 2014 09:48:20 -0700 |
parents | 2cda5a640ae7 |
children |
rev | line source |
---|---|
36 | 1 #!/usr/bin/env python |
2 | |
3 """(re)start the buildbot""" | |
4 | |
301
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
5 import argparse |
36 | 6 import os |
7 import sys | |
8 from subprocess import call | |
9 | |
282
2cda5a640ae7
make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents:
187
diff
changeset
|
10 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
|
11 debug = {{debug}} |
282
2cda5a640ae7
make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents:
187
diff
changeset
|
12 |
301
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
13 |
282
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:]): |
301
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
15 """CLI""" |
282
2cda5a640ae7
make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents:
187
diff
changeset
|
16 |
2cda5a640ae7
make this more of a script and add a --stop option
Jeff Hammel <jhammel@mozilla.com>
parents:
187
diff
changeset
|
17 # parse command line options |
301
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
18 parser = argparse.ArgumentParser(description=__doc__) |
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
19 parser.add_argument('--stop', dest='stop', |
282
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, |
301
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
21 help="stop the buildbot only; don't restart") |
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
22 # TODO: could force a build here: |
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
23 # buildbot sendchange ... |
aec0a7f8c191
STUB: autobot/template/restart_buildbot.py
Jeff Hammel <k0scist@gmail.com>
parents:
282
diff
changeset
|
24 options = 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() |