PageRenderTime 102ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 57ms app.codeStats 0ms

/silverlining/mgr-scripts/activate-instance.py

https://bitbucket.org/ianb/silverlining/
Python | 31 lines | 25 code | 5 blank | 1 comment | 3 complexity | 2fbbe8d706ea43d55a9a3318ba248ba3 MD5 | raw file
 1#!/usr/bin/env python
 2import sys
 3sys.path.insert(0, '/usr/local/share/silverlining/lib')
 4import optparse
 5from silversupport import appdata
 6
 7parser = optparse.OptionParser(
 8    usage='%prog HOST SITE')
 9
10parser.add_option(
11    '--debug-single-process',
12    action='store_true',
13    help='Set the activated application to be debug/threaded/single-process')
14
15
16def main():
17    options, args = parser.parse_args()
18    hostname, path = appdata.normalize_location(args[0])
19    instance_name = args[1]
20    if instance_name.lower() == 'prev':
21        instance_name = appdata.instance_for_location('prev.'+hostname, path)
22        if instance_name is None:
23            print 'There is no host at prev.%s%s to activate/revert' % (hostname, path)
24            return 1
25    appdata.add_appdata(
26        instance_name, [(hostname, path)],
27        debug_single_process=options.debug_single_process)
28    print '%s%s mapped to instance %s' % (hostname, path, instance_name)
29
30if __name__ == '__main__':
31    sys.exit(main())