def fetch_units(self, url, downloader): """ Fetch the units file referenced in the manifest. The file is decompressed and written to the path specified by units_path. :param url: The URL to the manifest. Used as the base URL. :type url: str :param downloader: The nectar downloader to be used. :type downloader: nectar.downloaders.base.Downloader :raise HTTPError: on URL errors. - :raise ValueError: on json decoding errors """ base_url = url.rsplit('/', 1)[0] url = '/'.join((base_url, os.path.basename(self.units_path))) request = DownloadRequest(str(url), self.units_path) request_list = [request] downloader.download(request_list) if compressed(self.units_path): self.units_path = decompress(self.units_path)
def fetch(self, url, dir_path, downloader): """ Fetch the manifest file using the specified URL. :param url: The URL to the manifest. :type url: str :param dir_path: The absolute path to a directory for the downloaded manifest. :type dir_path: str :param downloader: The nectar downloader to be used. :type downloader: nectar.downloaders.base.Downloader :raise HTTPError: on URL errors. - :raise ValueError: on json decoding errors """ destination = pathlib.join(dir_path, MANIFEST_FILE_NAME) request = DownloadRequest(str(url), destination) request_list = [request] downloader.download(request_list) if compressed(destination): destination = decompress(destination) with open(destination) as fp: manifest = json.load(fp) self.__dict__.update(manifest) self.units_path = pathlib.join(dir_path, os.path.basename(self.units_path))
def fetch(self, url, dir_path, downloader): """ Fetch the manifest file using the specified URL. :param url: The URL to the manifest. :type url: str :param dir_path: The absolute path to a directory for the downloaded manifest. :type dir_path: str :param downloader: The nectar downloader to be used. :type downloader: nectar.downloaders.base.Downloader :raise HTTPError: on URL errors. - :raise ValueError: on json decoding errors """ destination = os.path.join(dir_path, MANIFEST_FILE_NAME) request = DownloadRequest(str(url), destination) request_list = [request] downloader.download(request_list) if compressed(destination): destination = decompress(destination) with open(destination) as fp: manifest = json.load(fp) self.__dict__.update(manifest) self.units_path = os.path.join(dir_path, os.path.basename(self.units_path))