client.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:rekall-agent-server 作者: rekall-innovations 项目源码 文件源码
def wsdl_call_get_params(self, method, input, args, kwargs):
        """Build params from input and args/kwargs"""
        params = inputname = inputargs = None
        all_args = {}
        if input:
            inputname = list(input.keys())[0]
            inputargs = input[inputname]

        if input and args:
            # convert positional parameters to named parameters:
            d = {}
            for idx, arg in enumerate(args):
                key = list(inputargs.keys())[idx]
                if isinstance(arg, dict):
                    if key not in arg:
                        raise KeyError('Unhandled key %s. use client.help(method)' % key)
                    d[key] = arg[key]
                else:
                    d[key] = arg
            all_args.update({inputname: d})

        if input and (kwargs or all_args):
            if kwargs:
                all_args.update({inputname: kwargs})
            valid, errors, warnings = self.wsdl_validate_params(input, all_args)
            if not valid:
                raise ValueError('Invalid Args Structure. Errors: %s' % errors)
            # sort and filter parameters according to wsdl input structure
            tree = sort_dict(input, all_args)
            root = list(tree.values())[0]
            params = []
            # make a params tuple list suitable for self.call(method, *params)
            for k, v in root.items():
                # fix referenced namespaces as info is lost when calling call
                root_ns = root.namespaces[k]
                if not root.references[k] and isinstance(v, Struct):
                    v.namespaces[None] = root_ns
                params.append((k, v))
            # TODO: check style and document attributes
            if self.__soap_server in ('axis', ):
                # use the operation name
                method = method
            else:
                # use the message (element) name
                method = inputname
        #elif not input:
            #TODO: no message! (see wsmtxca.dummy)
        else:
            params = kwargs and kwargs.items()

        return (method, params)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号