本文整理汇总了Python中xmlrpc.client.ServerProxy.__getattr__方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.__getattr__方法的具体用法?Python ServerProxy.__getattr__怎么用?Python ServerProxy.__getattr__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpc.client.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.__getattr__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __request
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import __getattr__ [as 别名]
def __request(self, methodname, params):
method_function = ServerProxy.__getattr__(self, methodname)
self.__params = dict()
if (
params
and isinstance(params, tuple)
and isinstance(params[0], dict)
):
self.__params.update(params[0])
try:
response = method_function(self.__params)
except Fault as err:
raise NameError("Fault", err)
except ProtocolError as err:
raise NameError("ProtocolError", err)
except Exception as err:
raise NameError(
"Some other error occured, presumably with the network connection to %s"
% self.__address,
err,
)
if response["code"] < 2000:
try:
return response["resData"]
except:
# not all requests send a response
return None
else:
raise NameError(
"There was a problem: %s (Error code %s)"
% (response["msg"], response["code"]),
response,
)
示例2: fun
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import __getattr__ [as 别名]
def fun(*args, anonymous=False, **kwds):
if self.debug:
auth_msg = "[auth]" if not anonymous else "[anon]"
print("-> Sending {} {} on {} with args={} and kwds={}"
.format(auth_msg, attr, self, args, kwds))
actual_fun = ServerProxy.__getattr__(
self, attr)
try:
retcod = actual_fun(self.__auth__(anonymous), *args, **kwds)
if self.debug:
print("<- Received {}".format(retcod))
return retcod
except Exception as e:
print("ignored exception in {} : {}"
.format(attr, e))