当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.__getattr__方法代码示例

本文整理汇总了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,
            )
开发者ID:L3viathan,项目名称:inwx-dyndns,代码行数:36,代码来源:inwx.py

示例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))
开发者ID:parmentelat,项目名称:rhubarbe,代码行数:17,代码来源:plcapiproxy.py


注:本文中的xmlrpc.client.ServerProxy.__getattr__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。