mirror of
https://github.com/spiffcode/hostile-takeover.git
synced 2025-12-23 06:57:23 +00:00
30 lines
697 B
Python
Executable File
30 lines
697 B
Python
Executable File
#!/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])
|