alignak_backend_client/client.py
def decode(response):
        """
        Decodes and returns the response as JSON (dict) or raise BackendException
        :param response: requests.response object
        :return: dict
        """

        # Second stage. Errors are backend errors (bad login, bad url, ...)
        try:
            response.raise_for_status()
        except requests.HTTPError as e:
            raise BackendException(code=response.status_code,
                                   message=e,
                                   response=response)
        else:
            resp_json = response.json()
            # Catch errors not sent in a HTTP error
            error = resp_json.get('_error', None)
            if error:
                raise BackendException(code=error['code'],
                                       message=error['message'],
                                       response=response)
            return resp_json
def decode(response):
        """
        Decodes and returns the response as JSON (dict) or raise BackendException
        :param response: requests.response object
        :return: dict
        """

        # Second stage. Errors are backend errors (bad login, bad url, ...)
        try:
            response.raise_for_status()
        except requests.HTTPError as e:
            raise BackendException(code=response.status_code,
                                   message=e,
                                   response=response)
        else:
            resp_json = response.json()
            # Catch errors not sent in a HTTP error
            error = resp_json.get('_error', None)
            if error:
                raise BackendException(code=error['code'],
                                       message=error['message'],
                                       response=response)
            return resp_json
Decodes and returns the response as JSON (dict) or raise BackendException
        :param response: requests.response object
        :return: dict