예제 #1
0
    def fetch_metadata_file(self, file_name):
        file_url = self.file_url
        if not file_url or file_url == '':
            return

        metadata_files = []
        files = file_url.split("|")
        for curfile in files:
            cursource = curfile.split(";")
            if len(cursource) == 1:
                cursource.append("All")
            metadata_files.append(cursource)

        req = self._get_metadata_stream(metadata_files)

        try:
            self.file.seek(0)
            original_file_content = self.file.read()
            if compare_filecontents(original_file_content, req):
                return False
        except Exception:
            pass

        filename = path.basename("%s-metadata.xml" % file_name)
        self.file.delete(save=False)
        self.file.save(filename, ContentFile(req), save=False)
        return True
예제 #2
0
파일: base.py 프로젝트: GEANT/met
    def fetch_metadata_file(self, file_name):
        file_url = self.file_url
        if not file_url or file_url == '':
            return

        metadata_files = []
        files = file_url.split("|")
        for curfile in files:
            cursource = curfile.split(";")
            if len(cursource) == 1:
                cursource.append("All")
            metadata_files.append(cursource)

        req = self._get_metadata_stream(metadata_files)

        try:
            self.file.seek(0)
            original_file_content = self.file.read()
            if compare_filecontents(original_file_content, req):
                return False
        except Exception:
            pass

        filename = path.basename("%s-metadata.xml" % file_name)
        self.file.delete(save=False)
        self.file.save(filename, ContentFile(req), save=False)
        return True
예제 #3
0
파일: models.py 프로젝트: dpenezic/met
    def fetch_metadata_file(self):
        req = requests.get(self.file_url)
        if req.ok:
            req.raise_for_status()
        parsed_url = urlsplit(self.file_url)
        if self.file:
            self.file.seek(0)
            original_file_content = self.file.read()
            if compare_filecontents(original_file_content, req.content):
                return

        filename = path.basename(parsed_url.path)
        self.file.save(filename, ContentFile(req.content), save=False)