Exemplo n.º 1
0
def get_dov_xml(url, session=None):
    """Request the XML from the remote DOV webservices and return it.

    Parameters
    ----------
    url : str
        URL of the DOV object to download.
    session : requests.Session
        Session to use to perform HTTP requests for data. Defaults to None,
        which means a new session will be created for each request.

    Returns
    -------
    xml : bytes
        The raw XML data of this DOV object as bytes.

    """
    response = HookRunner.execute_inject_xml_response(url)

    if response is None:
        response = get_remote_url(url, session)

    HookRunner.execute_xml_received(url, response)

    return response
Exemplo n.º 2
0
    def get(self, url):
        datatype, key = self._get_type_key_from_url(url)

        data = HookRunner.execute_inject_xml_response(url)

        if data is not None:
            HookRunner.execute_xml_received(url, data)
            return data

        if self._is_valid(datatype, key):
            try:
                self._emit_cache_hit(url)
                data = self._load(datatype, key).encode('utf-8')

                HookRunner.execute_xml_received(url, data)
                return data

            except Exception:
                pass

        data = self._get_remote(url)
        try:
            self._save(datatype, key, data)
        except Exception:
            pass

        return data
Exemplo n.º 3
0
    def get(self, url):
        """Get the XML data for the DOV object referenced by the given URL.

        If a valid version exists in the cache, it will be loaded and
        returned. If no valid version exists, the XML will be downloaded
        from the DOV webservice, saved in the cache and returned.

        Parameters
        ----------
        url : str
            Permanent URL to a DOV object.

        Returns
        -------
        xml : bytes
            The raw XML data of this DOV object as bytes.

        """
        datatype, key = self._get_type_key_from_url(url)

        data = HookRunner.execute_inject_xml_response(url)

        if data is not None:
            HookRunner.execute_xml_received(url, data)
            return data

        if self._is_valid(datatype, key):
            try:
                self._emit_cache_hit(url)
                data = self._load(datatype, key).encode('utf-8')

                HookRunner.execute_xml_received(url, data)
                return data

            except Exception:
                pass

        data = self._get_remote(url)
        try:
            self._save(datatype, key, data)
        except Exception:
            pass

        return data
Exemplo n.º 4
0
def get_dov_xml(url):
    """Request the XML from the remote DOV webservices and return it.

    Parameters
    ----------
    url : str
        URL of the DOV object to download.

    Returns
    -------
    xml : bytes
        The raw XML data of this DOV object as bytes.

    """
    response = HookRunner.execute_inject_xml_response(url)

    if response is None:
        response = get_remote_url(url)

    HookRunner.execute_xml_received(url, response)

    return response