Exemple #1
0
 def _load(self):
     try:
         return self._make_request()
     except Exception as e:
         raise MetadataLoadError(
             "La richiesta all'endpoint HTTP '{}' è fallita: '{}'".format(
                 self._config.get('url'), e))
Exemple #2
0
 def _load(self):
     try:
         return self._read_file_text()
     except Exception as e:
         raise MetadataLoadError(
             "Impossibile leggere il file '{}': '{}'".format(
                 self._config, e))
Exemple #3
0
    def load(self, location):
        """
        Loads the SP metadata from HTTP.

        Args:
            location (str): The URL of the metadata to load.

        Returns:
            A ServiceProviderMetadata instance.

        Raises:
            MetadataLoadError: If the load fails.
        """

        try:
            response = requests.get(location)
            response.raise_for_status()
            metadata = ServiceProviderMetadata(response.content, self,
                                               location)
        except Exception as e:
            raise MetadataLoadError(
                "Request to HTTP endpoint '{}': '{}'".format(location, e))

        logger.debug("Loaded metadata for '{}` from '{}`".format(
            metadata.entity_id, location))

        return metadata
Exemple #4
0
 def __init__(self, conf):
     self._metadata = {}
     for file in conf:
         try:
             with open(file, 'rb') as fp:
                 metadata = ServiceProviderMetadata(fp.read())
                 self._metadata[metadata.entity_id] = metadata
                 logger.debug("Loaded metadata for: " + metadata.entity_id)
         except Exception as e:
             raise MetadataLoadError(
                 "Impossibile leggere il file '{}': '{}'".format(file, e))
Exemple #5
0
 def __init__(self, conf):
     self._metadata = {}
     for url in conf:
         try:
             response = requests.get(url)
             response.raise_for_status()
             metadata = ServiceProviderMetadata(response.content)
             self._metadata[metadata.entity_id] = metadata
         except Exception as e:
             raise MetadataLoadError(
                 "La richiesta all'endpoint HTTP '{}': '{}'".format(url, e))
Exemple #6
0
    def load(self, location):
        """
        Loads the SP metadata from file.

        Args:
            location (str): The path of file.

        Returns:
            A ServiceProviderMetadata instance.

        Raises:
            MetadataLoadError: If the load fails.
        """
        try:
            with open(location, 'rb') as fp:
                metadata = ServiceProviderMetadata(fp.read(), self, location)
        except (IOError, LxmlError) as e:
            raise MetadataLoadError("Failed to load '{}': '{}'".format(
                location, e))
        logger.debug("Loaded metadata for '{}` from '{}`".format(
            metadata.entity_id, location))
        return metadata