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


Python suds.WebFault方法代碼示例

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


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

示例1: _call

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def _call(self, function_name, args=None, kwargs=None):
        args = args or []
        kwargs = kwargs or {}
        func = getattr(self.client.service, function_name)
        # TODO: parse response, return something actually useful
        try:
            return func(*args, **kwargs)
        except WebFault as e:
            # Detect whether the failure is due to an invalid session, and if
            # possible, try to refresh the access token.
            if (hasattr(e, 'fault') and
                    e.fault.faultcode == 'sf:INVALID_SESSION_ID' and
                    self.rest_client):
                token = self.rest_client._refresh_token()
                if token:
                    self._set_session_header(token['access_token'])
                    return func(*args, **kwargs)
            raise 
開發者ID:heroku,項目名稱:python-salesforce-client,代碼行數:20,代碼來源:base.py

示例2: generate_dict

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [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

示例3: get_fault

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def get_fault(self, reply):
        """
        Extract the fault from the specified soap reply.  If I{faults} is True,
        an exception is raised.  Otherwise, the I{unmarshalled} fault L{Object}
        is returned.  This method is called when the server raises a
        I{web fault}.
        @param reply: A soap reply message.
        @type reply: str
        @return: A fault object.
        @rtype: tuple ( L{Element}, L{Object} )
        """
        reply = self.replyfilter(reply)
        sax = Parser()
        faultroot = sax.parse(string=reply)
        soapenv = faultroot.getChild('Envelope')
        soapbody = soapenv.getChild('Body')
        fault = soapbody.getChild('Fault')
        unmarshaller = self.unmarshaller(False)
        p = unmarshaller.process(fault)
        if self.options().faults:
            raise WebFault(p, faultroot)
        return (faultroot, p.detail) 
開發者ID:cackharot,項目名稱:suds-py3,代碼行數:24,代碼來源:binding.py

示例4: _update_real_server_port_status

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def _update_real_server_port_status(self, new_member):
        try:
            address = new_member['address']
            protocol_port = new_member['protocol_port']
            new_admin_state_up = new_member.get('admin_state_up')

            rs_server_port = self._adx_server_port(address, protocol_port)
            reply = (self.slb_service
                     .getRealServerPortConfiguration(rs_server_port))
            rs_port_conf_seq = (self.slb_factory.create
                                ('ArrayOfRealServerPortConfigurationSequence'))
            reply.rsPortConfig.serverPort = rs_server_port
            reply.rsPortConfig.adminState = new_admin_state_up

            rs_port_conf_list = [reply.rsPortConfig]
            rs_port_conf_seq.RealServerPortConfigurationSequence = rs_port_conf_list

            (self.slb_service
             .setRealServersPortConfiguration(rs_port_conf_seq))
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:23,代碼來源:adx_device_driver_impl.py

示例5: _update_real_server_properties

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def _update_real_server_properties(self, new_member):
        try:
            address = new_member['address']
            new_weight = new_member.get('weight')

            rs_server = self._adx_server(address)
            reply = (self.slb_service
                     .getRealServerConfiguration(rs_server))

            rs_conf_seq = (self.slb_factory.create
                           ('ArrayOfRealServerConfigurationSequence'))

            reply.rsConfig.leastConnectionWeight = new_weight

            # Work Around to fix bug in WSDL
            reply.rsConfig.byteRateThresold = None

            rs_conf_list = list()
            rs_conf_list.append(reply.rsConfig)
            rs_conf_seq.RealServerConfigurationSequence = rs_conf_list

            (self.slb_service
             .setRealServersConfiguration(rs_conf_seq))
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:27,代碼來源:adx_device_driver_impl.py

示例6: bind_member_to_vip

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def bind_member_to_vip(self, member, vip):
        rs_ip_address = member['address']
        rs_port = member['protocol_port']
        rs_name = member.get('name', rs_ip_address)

        vs_ip_address = vip['address']
        vs_port = vip['protocol_port']
        vs_name = vip['name']

        try:
            vs_server_port = self._adx_server_port(
                vs_ip_address, vs_port, vs_name)
            rs_server_port = self._adx_server_port(
                rs_ip_address, rs_port, rs_name)

            (self.slb_service
             .bindRealServerPortToVipPort(vs_server_port, rs_server_port))
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:21,代碼來源:adx_device_driver_impl.py

示例7: unbind_member_from_vip

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def unbind_member_from_vip(self, member, vip):

        rs_ip_address = member['address']
        rs_name = rs_ip_address
        rs_name = member.get('name', rs_ip_address)
        rs_port = member['protocol_port']

        vs_ip_address = vip['address']
        vs_port = vip['protocol_port']
        vs_name = vip['name']

        try:
            vs_server_port = self._adx_server_port(
                vs_ip_address, vs_port, vs_name)
            rs_server_port = self._adx_server_port(
                rs_ip_address, rs_port, rs_name)

            (self.slb_service
             .unbindRealServerPortFromVipPort(vs_server_port, rs_server_port))
            # Need to check alternate solutions rather than sleep
            # Is 5 seconds good enough ?
            time.sleep(5)
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:26,代碼來源:adx_device_driver_impl.py

示例8: set_predictor_on_virtual_server

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def set_predictor_on_virtual_server(self, vip):
        try:
            server = self._adx_server(vip['address'], vip['name'])
            lb_method = vip['lb_method']

            predictor_method_configuration = (self.slb_factory.create
                                              ('PredictorMethodConfiguration'))
            predictor = ADX_PREDICTOR_MAP.get(lb_method)
            if predictor:
                predictor_method_configuration.predictor = predictor
            else:
                error_message = ('Load Balancing Method/Predictor %s '
                                 'not supported') % (lb_method)
                LOG.error(error_message)
                raise adx_exception.UnsupportedFeature(msg=error_message)

            (self.slb_service
             .setPredictorOnVirtualServer(server,
                                          predictor_method_configuration))
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:23,代碼來源:adx_device_driver_impl.py

示例9: delete_vip

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def delete_vip(self, vip):
        address = vip['address']
        port = vip['protocol_port']

        vs_server_port = self._adx_server_port(address, port)
        vip_port_count = self._get_server_port_count(address, True)

        try:
            self.slb_service.deleteVirtualServerPort(vs_server_port)
        except suds.WebFault:
            pass

        try:
            if vip_port_count <= 2:
                self.slb_service.deleteVirtualServer(vs_server_port.srvr)
        except suds.WebFault as e:
            raise adx_exception.ConfigError(msg=e.message) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:19,代碼來源:adx_device_driver_impl.py

示例10: delete_health_monitor

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def delete_health_monitor(self, healthmonitor):
        name = healthmonitor['id']
        monitor_type = healthmonitor['type']

        if monitor_type in ['HTTP', 'HTTPS', 'TCP']:
            if not self._does_port_policy_exist(healthmonitor):
                LOG.debug('Health Monitor %s does not '
                          'exist on the device', name)
                return

            if not self._is_port_policy_in_use(name):
                try:
                    (self.slb_service
                     .deletePortPolicy(name))
                except suds.WebFault as e:
                    raise adx_exception.ConfigError(msg=e.message)
        elif monitor_type == 'PING':
            m = 'Delete of PING Monitor not supported'
            LOG.error(m)
            raise adx_exception.UnsupportedFeature(msg=m) 
開發者ID:globocom,項目名稱:GloboNetworkAPI,代碼行數:22,代碼來源:adx_device_driver_impl.py

示例11: test_reply_error_with_detail_with_fault

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def test_reply_error_with_detail_with_fault(monkeypatch):
    monkeypatch.delitem(locals(), "e", False)

    client = testutils.client_from_wsdl(_wsdl__simple_f, faults=True)

    for http_status in (http_client.OK, http_client.INTERNAL_SERVER_ERROR):
        inject = dict(reply=_fault_reply__with_detail, status=http_status)
        e = pytest.raises(suds.WebFault, client.service.f, __inject=inject)
        try:
            e = e.value
            _test_fault(e.fault, True)
            assert e.document.__class__ is suds.sax.document.Document
            assert str(e) == "Server raised fault: 'Dummy error.'"
        finally:
            del e  # explicitly break circular reference chain in Python 3

    inject = dict(reply=_fault_reply__with_detail,
        status=http_client.BAD_REQUEST, description="quack-quack")
    e = pytest.raises(Exception, client.service.f, __inject=inject).value
    try:
        assert e.__class__ is Exception
        assert e.args[0][0] == http_client.BAD_REQUEST
        assert e.args[0][1] == "quack-quack"
    finally:
        del e  # explicitly break circular reference chain in Python 3 
開發者ID:suds-community,項目名稱:suds,代碼行數:27,代碼來源:test_reply_handling.py

示例12: test_reply_error_without_detail_with_fault

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def test_reply_error_without_detail_with_fault(monkeypatch):
    monkeypatch.delitem(locals(), "e", False)

    client = testutils.client_from_wsdl(_wsdl__simple_f, faults=True)

    for http_status in (http_client.OK, http_client.INTERNAL_SERVER_ERROR):
        inject = dict(reply=_fault_reply__without_detail, status=http_status)
        e = pytest.raises(suds.WebFault, client.service.f, __inject=inject)
        try:
            e = e.value
            _test_fault(e.fault, False)
            assert e.document.__class__ is suds.sax.document.Document
            assert str(e) == "Server raised fault: 'Dummy error.'"
        finally:
            del e  # explicitly break circular reference chain in Python 3

    inject = dict(reply=_fault_reply__with_detail,
        status=http_client.BAD_REQUEST, description="quack-quack")
    e = pytest.raises(Exception, client.service.f, __inject=inject).value
    try:
        assert e.__class__ is Exception
        assert e.args[0][0] == http_client.BAD_REQUEST
        assert e.args[0][1] == "quack-quack"
    finally:
        del e  # explicitly break circular reference chain in Python 3 
開發者ID:suds-community,項目名稱:suds,代碼行數:27,代碼來源:test_reply_handling.py

示例13: test_request_handler_with_empty_web_fault_doc

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def test_request_handler_with_empty_web_fault_doc(self):

        def side_effect(mo, **kwargs):
            fault = mock.Mock(faultstring="MyFault")
            raise suds.WebFault(fault, None)

        svc_obj = service.Service()
        service_mock = svc_obj.client.service
        setattr(service_mock, 'powerOn', side_effect)

        ex = self.assertRaises(exceptions.VimFaultException,
                               svc_obj.powerOn,
                               'VirtualMachine')
        self.assertEqual([], ex.fault_list)
        self.assertEqual({}, ex.details)
        self.assertEqual("MyFault", ex.msg) 
開發者ID:openstack,項目名稱:oslo.vmware,代碼行數:18,代碼來源:test_service.py

示例14: raiseZoneNotFound

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def raiseZoneNotFound(self):
        fault = MockFault(str('102'),  '102 is zone not found')
        document = {}
        raise WebFault(fault, document) 
開發者ID:github,項目名稱:octodns,代碼行數:6,代碼來源:test_octodns_provider_transip.py

示例15: raiseInvalidAuth

# 需要導入模塊: import suds [as 別名]
# 或者: from suds import WebFault [as 別名]
def raiseInvalidAuth(self):
        fault = MockFault(str('200'),  '200 is invalid auth')
        document = {}
        raise WebFault(fault, document) 
開發者ID:github,項目名稱:octodns,代碼行數:6,代碼來源:test_octodns_provider_transip.py


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