當前位置: 首頁>>代碼示例>>Python>>正文


Python suds.MethodNotFound方法代碼示例

本文整理匯總了Python中suds.MethodNotFound方法的典型用法代碼示例。如果您正苦於以下問題:Python suds.MethodNotFound方法的具體用法?Python suds.MethodNotFound怎麽用?Python suds.MethodNotFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在suds的用法示例。


在下文中一共展示了suds.MethodNotFound方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_dict

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def generate_dict(api_obj, fields):
    result_dict = {}
    lists = []
    supported_fields = []
    if api_obj.get_list():
        for field in fields:
            try:
                api_response = getattr(api_obj, "get_" + field)()
            except (MethodNotFound, WebFault):
                pass
            else:
                lists.append(api_response)
                supported_fields.append(field)
        for i, j in enumerate(api_obj.get_list()):
            temp = {}
            temp.update([(item[0], item[1][i]) for item in zip(supported_fields, lists)])
            result_dict[j] = temp
    return result_dict 
開發者ID:f5devcentral,項目名稱:aws-deployments,代碼行數:20,代碼來源:bigip_facts.py

示例2: __getattr__

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def __getattr__(self, attr):
        # Looks up the corresponding suds method and returns a wrapped version.
        try:
            method = getattr(self._client.service, attr)
        except _MethodNotFound as e:
            e.__class__ = MethodNotFound
            raise

        wrapper = _wrap_method(method,
                self._wsdl_name,
                self._arg_factory(self._client, method),
                self._result_factory(),
                attr in self._usage and self._usage[attr] or None)
        setattr(self, attr, wrapper)
        return wrapper 
開發者ID:F5Networks,項目名稱:bigsuds,代碼行數:17,代碼來源:bigsuds.py

示例3: generate_simple_dict

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def generate_simple_dict(api_obj, fields):
    result_dict = {}
    for field in fields:
        try:
            api_response = getattr(api_obj, "get_" + field)()
        except (MethodNotFound, WebFault):
            pass
        else:
            result_dict[field] = api_response
    return result_dict 
開發者ID:f5devcentral,項目名稱:aws-deployments,代碼行數:12,代碼來源:bigip_facts.py

示例4: operation

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def operation(self, name):
        """
        Shortcut used to get a contained operation by name.
        @param name: An operation name.
        @type name: str
        @return: The named operation.
        @rtype: Operation
        @raise L{MethodNotFound}: When not found.
        """
        try:
            return self.operations[name]
        except Exception:
            raise MethodNotFound(name) 
開發者ID:cackharot,項目名稱:suds-py3,代碼行數:15,代碼來源:wsdl.py

示例5: _wrap_method

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def _wrap_method(method, wsdl_name, arg_processor, result_processor, usage):
    """
    This function wraps a suds method and returns a new function which
    provides argument/result processing.

    Each time a method is called, the incoming args will be passed to the
    specified arg_processor before being passed to the suds method.

    The return value from the underlying suds method will be passed to the
    specified result_processor prior to being returned to the caller.

    @param method: A suds method (can be obtained via
        client.service.<method_name>).
    @param arg_processor: An instance of L{_ArgProcessor}.
    @param result_processor: An instance of L{_ResultProcessor}.

    """

    icontrol_sig = "iControl signature: %s" % _method_string(method)

    if usage:
        usage += "\n\n%s" % icontrol_sig
    else:
        usage = "Wrapper for %s.%s\n\n%s" % (
            wsdl_name, method.method.name, icontrol_sig)

    def wrapped_method(*args, **kwargs):
        log.debug('Executing iControl method: %s.%s(%s, %s)',
                  wsdl_name, method.method.name, args, kwargs)
        args, kwargs = arg_processor.process(args, kwargs)
        # This exception wrapping is purely for pycontrol compatability.
        # Maybe we want to make this optional and put it in a separate class?
        try:
            result = method(*args, **kwargs)
        except AttributeError:
            # Oddly, this seems to happen when the wrong password is used.
            raise ConnectionError('iControl call failed, possibly invalid '
                    'credentials.')
        except _MethodNotFound as e:
            e.__class__ = MethodNotFound
            raise
        except WebFault as e:
            e.__class__ = ServerError
            raise
        except URLError as e:
            raise ConnectionError('URLError: %s' % str(e))
        except BadStatusLine as e:
            raise ConnectionError('BadStatusLine: %s' %  e)
        except SAXParseException as e:
            raise ParseError("Failed to parse the BIGIP's response. This "
                "was likely caused by a 500 error message.")
        return result_processor.process(result)

    wrapped_method.__doc__ = usage
    wrapped_method.__name__ = str(method.method.name)
    # It's occasionally convenient to be able to grab the suds object directly
    wrapped_method._method = method
    return wrapped_method 
開發者ID:F5Networks,項目名稱:bigsuds,代碼行數:60,代碼來源:bigsuds.py

示例6: do_cmd

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import MethodNotFound [as 別名]
def do_cmd(self, line):
        '''Usage: CMD service operation [parameters]'''
        try:
            args = self.cmd_parser.parse_args(line.split())
        except ValueError as err:
            return error(err)

        # Check if args.service is valid
        if args.service not in SUPPORTED_SERVICES:
            return error('No Service: ' + args.service)

        args.params = ''.join(args.params)
        # params is optional
        if not args.params.strip():
            args.params = '{}'

        # params must be a dictionary format string
        match = re.match(r"^.*?(\{.*\}).*$", args.params)
        if not match:
            return error('Invalid params')

        try:
            args.params = dict(literal_eval(match.group(1)))
        except ValueError as err:
            return error('Invalid params')

        try:
            # Get ONVIF service
            service = self.client.get_service(args.service)
            # Actually execute the command and get the response
            response = getattr(service, args.operation)(args.params)
        except MethodNotFound as err:
            return error('No Operation: %s' % args.operation)
        except Exception as err:
            return error(err)

        if isinstance(response, (Text, bool)):
            return success(response)
        # Try to convert instance to dictionary
        try:
            success(ONVIFService.to_dict(response))
        except ONVIFError:
            error({}) 
開發者ID:quatanium,項目名稱:python-onvif,代碼行數:45,代碼來源:cli.py


注:本文中的suds.MethodNotFound方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。