本文整理汇总了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
示例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
示例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
示例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)
示例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
示例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({})