Skip to content

Instantly share code, notes, and snippets.

@canassa
Created January 17, 2018 13:59
Show Gist options
  • Save canassa/1132704f85dbaf55a8c21e546f7ec72d to your computer and use it in GitHub Desktop.
Save canassa/1132704f85dbaf55a8c21e546f7ec72d to your computer and use it in GitHub Desktop.
A XMLRPC client that leverages the requests library
import functools
from xmlrpc.client import dumps, loads
from requests import session
class XMLRPC:
def __init__(self, url):
self.session = session(url)
def __getattr__(self, name):
return functools.partial(self._call, name)
def _call(self, name, *params):
response = self.session.post('', data=dumps(params, name))
return loads(response.text)[0][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment