diff --git a/install.ps1 b/install.ps1 index a269b6a3..922c553e 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "0c3089832c2ee7e61b50a49edcd9a810814be8b5465238755b3954ff895c5e18" +$defaultInstallSha256 = "324baf5363d46da75cb7f166e83b323a40ce6502084314360f909e9d1ff4dd4e" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index f894fd97..e200f844 100644 --- a/install.py +++ b/install.py @@ -1753,12 +1753,17 @@ def _fetch_json(url: str, limit: int, label: str) -> object: if exc.code < 500 and exc.code != 429 or attempt == MAX_RETRIES: raise delay = _retry_delay(attempt, exc.headers.get("Retry-After") if exc.headers else None) + problem = f"HTTP {exc.code}" except (urllib.error.URLError, OSError, http.client.HTTPException) as exc: if attempt == MAX_RETRIES: if isinstance(exc, http.client.HTTPException): raise ConnectionError(f"connection cut: {exc!r}") from exc raise delay = _retry_delay(attempt, None) + problem = str(getattr(exc, "reason", None) or exc) + # Said, or three 30-second attempts read as a frozen program. + print(f" The {label} did not arrive ({problem}); trying again " + f"({attempt + 1}/{MAX_RETRIES}) in {delay:.0f} s.", file=sys.stderr) time.sleep(delay) raise AssertionError("unreachable") diff --git a/install.sh b/install.sh index fe75e117..f3e568b3 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="0c3089832c2ee7e61b50a49edcd9a810814be8b5465238755b3954ff895c5e18" +DEFAULT_INSTALL_SHA256="324baf5363d46da75cb7f166e83b323a40ce6502084314360f909e9d1ff4dd4e" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install.py b/tests/test_install.py index ab3ea785..c6f64238 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -2470,6 +2470,19 @@ class ACutFileListIsRetried(unittest.TestCase): unittest.mock.patch.object(install.time, "sleep"): self.assertEqual(install._fetch_json("https://x/y.json", 1000, "manifest"), {"a": 1}) + def test_a_retry_is_announced(self): + import contextlib + + full = json.dumps({"a": 1}).encode() + answers = iter([self._Response(full[:4], len(full)), self._Response(full, len(full))]) + err = io.StringIO() + with unittest.mock.patch.object(install.urllib.request, "urlopen", + lambda *a, **k: next(answers)), \ + unittest.mock.patch.object(install.time, "sleep"), \ + contextlib.redirect_stderr(err): + install._fetch_json("https://x/y.json", 1000, "file list") + self.assertIn("trying again (2/3)", err.getvalue()) + def test_a_short_body_is_a_connection_error(self): with self.assertRaises(ConnectionError): install._read_limited_json(self._Response(b'{"a"', 10), 1000, "manifest")