From 763ae779ffb43ea9d33a9bf2a1c6c4ca78ef243d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 29 Apr 2008 14:50:27 +0000 Subject: From: Dr Scofield * Fixes the admin_shutdown xmlrpc method * Adds a share/python/console/shutdown.py script for shutting down a background OpenSim * For more details see http://xyzzyxyzzy.net/2008/04/29/console-less-opensim/ * There should also be instructions in the opensimulator wiki soon as well --- share/python/console/shutdown.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 share/python/console/shutdown.py (limited to 'share/python') diff --git a/share/python/console/shutdown.py b/share/python/console/shutdown.py new file mode 100644 index 0000000..65f8255 --- /dev/null +++ b/share/python/console/shutdown.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# -*- encoding: utf-8 -*- + +import ConfigParser +import xmlrpclib +import optparse +import os.path + +if __name__ == '__main__': + parser = optparse.OptionParser() + parser.add_option('-c', '--config', dest = 'config', help = 'config file', metavar = 'CONFIG') + parser.add_option('-s', '--server', dest = 'server', help = 'URI for the grid server', metavar = 'SERVER') + parser.add_option('-p', '--password', dest = 'password', help = 'password for the grid server', metavar = 'PASSWD') + (options, args) = parser.parse_args() + + configFile = options.config + if not configFile: + if os.path.isfile(os.path.expanduser('~/.opensim-console.rc')): + configFile = os.path.expanduser('~/.opensim-console.rc') + if not configFile: + parser.error('missing option config') + sys.exit(1) + + config = ConfigParser.ConfigParser() + config.readfp(open(configFile)) + + server = config.get('opensim', 'server') + password = config.get('opensim', 'password') + + if options.server: server = options.server + if options.password: password = options.password + + gridServer = xmlrpclib.Server(server) + res = gridServer.admin_shutdown({'password': password}) + + if res['success'] == 'true': + print 'shutdown of %s initiated' % server + else: + print 'shutdown of %s failed' % server -- cgit v1.1