User:Allen Kerensky/JSON Grid SimStats

From OpenSimulator

< User:Allen Kerensky
Revision as of 20:52, 8 February 2013 by Allen Kerensky (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

JSON Grid Simstats

Archived from Test Page

Python example to gain the region data from a grid service

- should work but this version not tested -
        *reference material* 
import hashlib
 import urllib2
 
 ''' value shown is an example, get this from your grid database each time - regions.regionSecret '''
 regionsecret = 'fe21314b-6267-44f7-aa1e-6047e1c3f94a'
 
 ''' My region host '''
 hostName =  myregion.host.net
 
 ''' My region port '''
 hostPort = 9000
 
 ''' create an *UPPERCASE* SHA1 hash from the regionSecret '''
 resourceName = str(hashlib.sha1(regionsecret).hexdigest()).upper()
 
 regionuri = hostName + ":" + hostPort + "/" + resourceName + "/"
 
 ''' data includes TimeZoneName , TimeZoneOffs, UxTime, Memory, Version and OSStatsURI '''
 regiondata = simplejson.load(urllib2.urlopen(regionuri))
 
 ''' OSStatsURI is the uri to query the OpenSim instance. return same data as the user set uri '''
 simuri = regiondata['OSStatsURI']
 
 simdata = simplejson.load(urllib2.urlopen(simuri))
Personal tools
General
About This Wiki