0

I'm working on an application in which a server and client are being created; the ServerAPI is using SimpleXMLRPCServer and the ClientAPI is using xmlrpclib. The client is initiated with:

class w_Client:
        def __init__(self, ServerIP, ServerPort, ClientIP):
                self.conn = xmlrpclib.ServerProxy("http://" + ServerIP + ":" + str(ServerPort))
                self.ClientIP = ClientIP

upon a button being pressed in the application, an xml specification file is created and passed thru

        def Create(self, XMLstring):
            return self.conn.Create(XMLstring, self.ClientIP)

I've already checked to make sure that the XMLstring is valid XML; however, when I get press the button, I get the following error:

Traceback (most recent call last):

  File "/home/app/UI/MainWindow.py", line 461, in compile
    xmlFile = compiler.compile()
  File "/home/app/Core/Compiler.py", line 75, in compile
    self.compile_top()
  File "/home/app/Core/Compiler.py", line 354, in compile_top
    status = mainWidgets["w_client"].Create(xmlString)
  File "/home/app/Wireless/ClientAPI.py", line 12, in Create
    return self.conn.Create(XMLstring, self.ClientIP)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1591, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:'NoneType' object has no attribute '__getitem__'">

I've also made sure that the ClientIP is passed correctly. Otherwise, I'm not entirely sure what's going on or how to even go about fixing it.

cerremony
  • 213
  • 2
  • 12

1 Answers1

1
<type 'exceptions.TypeError'>:'NoneType' object has no attribute '__getitem__'

This exception may have been generated by the xmlrpc method you were calling (i.e. server side).

I suggest that you add verbose=True to your instantiation of the server proxy:

xmlrpclib.ServerProxy("http://" + ServerIP + ":" + str(ServerPort),verbose=True)

This will allow you to see what you're sending and receiving.

It seems the method you're calling is expecting a dict

MattH
  • 37,273
  • 11
  • 82
  • 84
  • How do I know that it's expecting a dict, and which method in particular? I'm not quite sure. – cerremony Sep 24 '15 at 16:56
  • I'm guessing. `__getitem__` is the method for retrieving a value for a key, but `None` doesn't have this method. I.e. some code received a `None` when it was expecting a `dict`. – MattH Sep 25 '15 at 13:11
  • Do you mean the `Create` method? – cerremony Nov 05 '15 at 21:21