PageRenderTime 46ms CodeModel.GetById 10ms RepoModel.GetById 0ms 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
Possible License(s): GPL-2.0
  1. #!/usr/bin/env python
  2. import sys
  3. sys.path.insert(0, '/usr/local/share/silverlining/lib')
  4. import optparse
  5. from silversupport import appdata
  6. parser = optparse.OptionParser(
  7. usage='%prog HOST SITE')
  8. parser.add_option(
  9. '--debug-single-process',
  10. action='store_true',
  11. help='Set the activated application to be debug/threaded/single-process')
  12. def main():
  13. options, args = parser.parse_args()
  14. hostname, path = appdata.normalize_location(args[0])
  15. instance_name = args[1]
  16. if instance_name.lower() == 'prev':
  17. instance_name = appdata.instance_for_location('prev.'+hostname, path)
  18. if instance_name is None:
  19. print 'There is no host at prev.%s%s to activate/revert' % (hostname, path)
  20. return 1
  21. appdata.add_appdata(
  22. instance_name, [(hostname, path)],
  23. debug_single_process=options.debug_single_process)
  24. print '%s%s mapped to instance %s' % (hostname, path, instance_name)
  25. if __name__ == '__main__':
  26. sys.exit(main())