Exemple #1
0
    def get_capabilities(self):
        """ Start a network call to retrieve the original capabilities xml document.

        Using the connector class, this function will GET the capabilities xml document as string.
        No file will be downloaded and stored on the storage. The string will be stored in the OGCWebService instance.

        Returns:
             nothing
        """
        params = {
            "request":
            OGCOperationEnum.GET_CAPABILITIES.value,
            "version":
            self.service_version.value
            if self.service_version is not None else "",
            "service": (self.service_type.value
                        if self.service_type is not None else "").upper(),
        }
        concat = "&" if self.service_connect_url[-1] != "&" else ""
        self.service_connect_url = "{}{}{}".format(self.service_connect_url,
                                                   concat, urlencode(params))
        ows_connector = CommonConnector(
            url=self.service_connect_url,
            external_auth=self.external_authentification,
            connection_type=ConnectionEnum.REQUESTS)
        ows_connector.http_method = 'GET'
        try:
            ows_connector.load()
            if ows_connector.status_code != 200:
                raise ConnectionError(ows_connector.status_code)
        except ReadTimeout:
            raise ConnectionError(
                CONNECTION_TIMEOUT.format(self.service_connect_url))

        tmp = ows_connector.content.decode("UTF-8")
        # check if tmp really contains an xml file
        xml = xml_helper.parse_xml(tmp)

        if xml is None:
            raise Exception(tmp)

        self.service_capabilities_xml = tmp
        self.connect_duration = ows_connector.run_time
        self.descriptive_document_encoding = ows_connector.encoding
    def get_metadata(self):
        """ Start a network call to retrieve the original capabilities xml document.

        Using the connector class, this function will GET the capabilities xml document as string.
        No file will be downloaded and stored on the storage. The string will be stored in the OGCWebService instance.

        Returns:
             nothing
        """
        ows_connector = CommonConnector(
            url=self.uri,
            external_auth=None,
            connection_type=ConnectionEnum.REQUESTS)
        ows_connector.http_method = 'GET'
        ows_connector.load()
        if ows_connector.status_code != 200:
            raise ConnectionError(ows_connector.status_code)

        self.raw_metadata = ows_connector.content.decode("UTF-8")