view 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
line wrap: on
line source

#!/usr/bin/env python

"""(re)start the buildbot"""

import optparse
import os
import sys
from subprocess import call
from time import sleep

here = os.path.abspath(os.path.dirname(sys.argv[0]))
debug = {{debug}}

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)

    # 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()