# HG changeset patch # User Jeff Hammel # Date 1343854855 25200 # Node ID 2cda5a640ae76f8b1c17395bb6495783f5228bd9 # Parent 6ac4cfa284654d738872b903b871115167743525 make this more of a script and add a --stop option diff -r 6ac4cfa28465 -r 2cda5a640ae7 autobot/template/restart_buildbot.py --- a/autobot/template/restart_buildbot.py Tue Jul 31 17:04:36 2012 -0700 +++ b/autobot/template/restart_buildbot.py Wed Aug 01 14:00:55 2012 -0700 @@ -2,22 +2,42 @@ """(re)start the buildbot""" +import optparse import os import sys from subprocess import call from time import sleep -os.chdir(os.path.abspath(os.path.dirname(sys.argv[0]))) - +here = os.path.abspath(os.path.dirname(sys.argv[0])) debug = {{debug}} -if debug: - call(['rm', '-f', 'master/twistd.log']) - call(['rm', '-f', 'slave/twistd.log']) - call(['rm', '-rf', 'slave/full']) -call(['buildbot', 'stop', 'master']) -call(['buildslave', 'stop', 'slave']) -call(['buildbot', 'start', 'master']) -call(['buildslave', 'start', 'slave']) + +def main(args=sys.argv[1:]): + + # parse command line options + usage = '%prog [options]' + parser = optparse.OptionParser(usage=usage, description=__doc__) + parser.add_option('--stop', dest='stop', + action='store_true', default=False, + help="stop the buildbot only") + # could force a build here + # buildbot sendchange ... + options, args = parser.parse_args(args) -# could force a build here -# buildbot sendchange ... + # cleanup + if debug: + call(['rm', '-f', 'master/twistd.log'], cwd=here) + call(['rm', '-f', 'slave/twistd.log'], cwd=here) + call(['rm', '-rf', 'slave/full'], cwd=here) + + # stop running instance + call(['buildbot', 'stop', 'master'], cwd=here) + call(['buildslave', 'stop', 'slave'], cwd=here) + + # start new instance + if not options.stop: + call(['buildbot', 'start', 'master'], cwd=here) + call(['buildslave', 'start', 'slave'], cwd=here) + + +if __name__ == '__main__': + main()