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
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)