我无法在xmlrpclib.ServerProxy()上获得方法列表.我尝试过使用dir(); 但是,解释器会一直返回错误.
这是我试过的:
>>>s = xmlrpclib.ServerProxy("http://192.168.1.72:8888")
>>>dir(s)
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "__dir__" is not supported'>
Run Code Online (Sandbox Code Playgroud)
不支持Dir(),如何获取方法列表?
我可能错了,但我怀疑你真正追求的是远程系统支持的方法,它将被代理(按需)到本地对象.
如果服务器支持XML introspection API,则可以使用该ServerProxy.system.listMethods()方法...
>>> s = xmlrpclib.ServerProxy("http://192.168.1.72:8888")
>>> s.system.listMethods()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7884 次 |
| 最近记录: |