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

#!/usr/bin/env python

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

import argparse
import os
import sys
from subprocess import call

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


def main(args=sys.argv[1:]):
    """CLI"""

    # parse command line options
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--stop', dest='stop',
                      action='store_true', default=False,
                      help="stop the buildbot only; don't restart")
    # TODO: could force a build here:
    #  buildbot sendchange ...
    options = 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()