aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/share/python/console/shutdown.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/python/console/shutdown.py')
-rw-r--r--share/python/console/shutdown.py39
1 files changed, 39 insertions, 0 deletions
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 @@
1#!/usr/bin/python
2# -*- encoding: utf-8 -*-
3
4import ConfigParser
5import xmlrpclib
6import optparse
7import os.path
8
9if __name__ == '__main__':
10 parser = optparse.OptionParser()
11 parser.add_option('-c', '--config', dest = 'config', help = 'config file', metavar = 'CONFIG')
12 parser.add_option('-s', '--server', dest = 'server', help = 'URI for the grid server', metavar = 'SERVER')
13 parser.add_option('-p', '--password', dest = 'password', help = 'password for the grid server', metavar = 'PASSWD')
14 (options, args) = parser.parse_args()
15
16 configFile = options.config
17 if not configFile:
18 if os.path.isfile(os.path.expanduser('~/.opensim-console.rc')):
19 configFile = os.path.expanduser('~/.opensim-console.rc')
20 if not configFile:
21 parser.error('missing option config')
22 sys.exit(1)
23
24 config = ConfigParser.ConfigParser()
25 config.readfp(open(configFile))
26
27 server = config.get('opensim', 'server')
28 password = config.get('opensim', 'password')
29
30 if options.server: server = options.server
31 if options.password: password = options.password
32
33 gridServer = xmlrpclib.Server(server)
34 res = gridServer.admin_shutdown({'password': password})
35
36 if res['success'] == 'true':
37 print 'shutdown of %s initiated' % server
38 else:
39 print 'shutdown of %s failed' % server