Python Forum

Full Version: xmlrpc.client, ServerProxy and null return
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a simple bit of code that accesses an XMLRPC server in this case to delete some user accounts.

def __init__(self, host, token):
    url = host + '/webservice/xmlrpc/server.php?wstoken=' + token
    self.proxy = xmlrpc.client.ServerProxy(url)

def core_user_delete_users(self, id):
    ids = [id]
    self.proxy.core_user_delete_users(ids)
    return
Now this actually works fine. The server correctly deletes the users. However, it (also) correctly returns nothing at all to the client. This (I am assuming anyway) causes an error...

Error:
File "pymoosh.py", line 62, in <module> moodle.core_user_delete_users(id) File "/home/howard/Repos/webservice/moodle.py", line 14, in core_user_delete_users self.proxy.core_user_delete_users(ids) File "/usr/lib/python3.5/xmlrpc/client.py", line 1092, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.5/xmlrpc/client.py", line 1432, in __request verbose=self.__verbose File "/usr/lib/python3.5/xmlrpc/client.py", line 1134, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.5/xmlrpc/client.py", line 1150, in single_request return self.parse_response(resp) File "/usr/lib/python3.5/xmlrpc/client.py", line 1320, in parse_response p.close() File "/usr/lib/python3.5/xmlrpc/client.py", line 447, in close parser.Parse(b"", True) # end of data xml.parsers.expat.ExpatError: no element found: line 1, column 0
As it basically works, I am assuming that this is complaining about no response being sent.

Is this the case and/or is there some way around it?