How to use the zeep.exceptions function in zeep

To help you get started, we’ve selected a few zeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mvantellingen / python-zeep / tests / test_xsd_schemas.py View on Github external
def test_default_types_not_found():
    schema = xsd.Schema()
    with pytest.raises(exceptions.LookupError):
        schema.get_type("{http://www.w3.org/2001/XMLSchema}bar")
github mvantellingen / python-zeep / src / zeep / xsd / elements / any.py View on Github external
continue

        # Lookup type via xsi:type attribute
        xsd_type = qname_attr(xmlelement, xsi_ns("type"))
        if xsd_type is not None:
            xsd_type = schema.get_type(xsd_type)
            return xsd_type.parse_xmlelement(xmlelement, schema, context=context)

        # Check if a restrict is used
        if self.restrict:
            return self.restrict.parse_xmlelement(xmlelement, schema, context=context)

        try:
            element = schema.get_element(xmlelement.tag)
            return element.parse(xmlelement, schema, context=context)
        except (exceptions.NamespaceError, exceptions.LookupError):
            return xmlelement
github meyt / payit / payit / gateways / mellat.py View on Github external
}
            client = Client(self._server_url)
            if 'proxies' in self.config:
                client.transport.session.proxies = self.config['proxies']

            result = client.service.bpVerifyRequest(**params)
            if int(result) != 0:
                client.service.bpReversalRequest(**params)
                raise TransactionError('Mellat: invalid transaction, code: %s ' % result)

            result = client.service.bpSettleRequest(**params)
            if int(result) != 0:
                client.service.bpReversalRequest(**params)
                raise TransactionError('Mellat: invalid transaction, code: %s ' % result)

        except zeep_exceptions.Error:
            raise GatewayNetworkError

        return transaction
github PEDIA-Charite / PEDIA-workflow / lib / api / mutalyzer.py View on Github external
def get_db_snp_descriptions(self, rs_id: str) -> [str]:
        '''Return a list of possible RS numbers for the given RS code.
        '''
        tries = 0
        while tries < 5:
            try:
                variants = self.service.getdbSNPDescriptions(rs_id)
                break
            except zeep.exceptions.Fault as error:
                print(error)
                tries += 1
        return variants
github cornershop / python-tbk / tbk / soap / zeep_client.py View on Github external
def request(self, request, timeout=None):
        try:
            timeout = timeout or self.transport_timeout
            with self.transport.settings(timeout=timeout):
                method = self.get_method(request.method_name)
                result = method(*request.args, **request.kwargs)
        except zeep.exceptions.Fault as fault:
            self.logger.exception("Fault")
            error, code = parse_tbk_error_message(fault.message)
            raise SoapServerException(error, code, request)
        except RequestException as error:
            self.logger.exception("Request exception")
            raise SoapRequestException(error, request)
        else:
            serialized = zeep.helpers.serialize_object(result)
            last_sent = self.get_last_sent_envelope()
            last_received = self.get_last_received_envelope()
            return serialized, last_sent, last_received
github mvantellingen / python-zeep / src / zeep / xsd / elements / element.py View on Github external
def _validate_item(self, value, render_path):
        if self.nillable and value in (None, NotSet):
            return

        try:
            self.type.validate(value, required=True)
        except exceptions.ValidationError as exc:
            raise exceptions.ValidationError(
                "The element %s is not valid: %s" % (self.qname, exc.message),
                path=render_path,
            )