def download(self, url=None): if self.download_url is None and url is None: return downloaded_file = TemporaryFile() result = https.open(self.download_url) shutil.copyfileobj(result, downloaded_file) downloaded_file.seek(0) return downloaded_file
def download(self, url=None, dst_filename=None): if self.download_url is None and url is None: return if dst_filename is None: dst_filename = self.dst_filename try: os.makedirs(self.dst_directory) except OSError as exc: if exc.errno != 17: raise exc downloaded_file = open(dst_filename, "w+") result = https.open(self.download_url) shutil.copyfileobj(result, downloaded_file) downloaded_file.seek(0) return downloaded_file