-
Notifications
You must be signed in to change notification settings - Fork 0
Common Example Code
Accalia de Elementia edited this page Jun 22, 2012
·
2 revisions
#Common code used by all examples in this wiki
#!/usr/bin/env python2
from xmlrpclib import ServerProxy
import json
from random import random
from urllib2 import Request, urlopen
def JSONRPC2(command, params):
method = {'jsonrpc': '2.0', 'method': command, 'params':params, 'id':1}
req = Request('http://localhost:8080/json',json.dumps(method),
{'Content-Type': 'application/json'})
resp = json.loads(urlopen(req).read())
return resp.get('result', resp)
XMLRPC = ServerProxy('http://localhost:8080/xml')