diff --git a/bob/devtools/mirror.py b/bob/devtools/mirror.py index 9c13a54b78338ee1a890e1c753f2abe9c5fbcfc7..1d05fab9a14d5422d298fca6c1efc55ae68e023a 100644 --- a/bob/devtools/mirror.py +++ b/bob/devtools/mirror.py @@ -80,7 +80,7 @@ def get_json(channel, platform, name): ---------- channel : str Complete channel URL - platform : {'linux-64', 'osx-64', 'noarch'} + platform : {'linux-64', 'osx-64', 'osx-arm64', 'noarch'} The platform of interest name : str The name of the file to retrieve. If the name ends in '.bz2', then it @@ -90,11 +90,18 @@ def get_json(channel, platform, name): ------- repodata : dict contents of repodata.json + + Raises + ------ + RuntimeError : + If the URL cannot be reached """ url = channel + "/" + platform + "/" + name logger.debug("[checking] %s...", url) r = requests.get(url, allow_redirects=True, stream=True) + if r.status_code == 404: + raise RuntimeError("URL '%s' does not exist" % url) size = r.headers.get("Content-length", "??") logger.info("[download] %s (%s bytes)...", url, size) @@ -374,7 +381,8 @@ def checksum_packages(repodata, dest_dir, arch, packages): dest_dir : str Path leading to local mirror arch : str - Current architecture being considered (e.g. noarch, linux-64 or osx-64) + Current architecture being considered (e.g. noarch, linux-64, osx-64, + osx-arm64) packages : list List of packages that are available locally, by name diff --git a/bob/devtools/scripts/mirror.py b/bob/devtools/scripts/mirror.py index fcd9de0c7708a3ad6cb4ac8cda9bc57ebb1d5a2d..3ffbeaec621eede0e1bbf125d38cd8b666254d43 100644 --- a/bob/devtools/scripts/mirror.py +++ b/bob/devtools/scripts/mirror.py @@ -169,7 +169,7 @@ def mirror( logger.warn("!!!! DRY RUN MODE !!!!") logger.warn("Nothing will be really mirrored") - DEFAULT_SUBDIRS = ["noarch", "linux-64", "osx-64"] + DEFAULT_SUBDIRS = ["noarch", "linux-64", "osx-64", "osx-arm64"] noarch = os.path.join(dest_dir, "noarch") if not os.path.exists(noarch): # first time @@ -188,7 +188,18 @@ def mirror( for arch in DEFAULT_SUBDIRS: - remote_repodata = get_json(channel_url, arch, "repodata_from_packages.json.bz2") + try: + remote_repodata = get_json( + channel_url, arch, "repodata_from_packages.json.bz2" + ) + except RuntimeError: + # the architecture does not exist? + logger.warning( + "Architecture %s does not seem to exist at channel %s - ignoring...", + arch, + channel_url, + ) + continue # merge all available packages into one single dictionary remote_package_info = {}