INNER CODE UNIT · Python

mirror_is_reachable

PKU-EMBL/BASALT · BASALT_setup_China_mainland.py:266

def mirror_is_reachable(channels: Sequence[str], timeout: float = 4.0) -> bool:
    """Probe noarch repodata without changing package-manager state."""
    for channel in channels:
        url = channel.rstrip("/") + "/noarch/repodata.json.zst"
        request = Request(
            url,
            headers={"User-Agent": "BASALT-installer/1.2", "Range": "bytes=0-0"},
        )
        try:
            with urlopen(request, timeout=timeout) as response:
                if response.status not in (200, 206):
                    return False
        except (HTTPError, URLError, TimeoutError, OSError):
            return False
    return True


def resolve_mirror(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…