mirror of
https://github.com/spiffcode/hostile-takeover.git
synced 2026-04-10 21:11:29 -06:00
Added utility to list currently running server instances
This commit is contained in:
parent
0d3183e58b
commit
3032e898fb
29
server/docker/instances
Executable file
29
server/docker/instances
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python2.7
|
||||
|
||||
import urllib2
|
||||
import json
|
||||
import sys
|
||||
import config
|
||||
|
||||
url = 'http://%s/api/serverinfo' % config.get('LEADERBOARD_ADDRESS_AND_PORT')
|
||||
|
||||
opener = urllib2.build_opener(urllib2.HTTPHandler)
|
||||
request = urllib2.Request(url)
|
||||
request.get_method = lambda: 'GET'
|
||||
|
||||
try:
|
||||
response = opener.open(request).read()
|
||||
except urllib2.HTTPError, e:
|
||||
print e.code
|
||||
print e.read()
|
||||
sys.exit(1)
|
||||
|
||||
infos = json.loads(response)
|
||||
for info in infos['infos']:
|
||||
print 'Name: %s, status: %s' % (info['name'], info['status'])
|
||||
keys = info.keys()
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
if key == 'name' or key == 'status':
|
||||
continue
|
||||
print ' %s: %s' % (key, info[key])
|
||||
Loading…
Reference in New Issue
Block a user