From 37fc53a29cf10d689ab87686bfa0a10f78551714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Sun, 15 Mar 2026 15:06:43 -0400 Subject: [PATCH] Fail silently if version check fails Closes #63 Co-Authored-By: Claude Sonnet 4.6 --- ctf/__init__.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ctf/__init__.py b/ctf/__init__.py index 245a937..8be1ff6 100644 --- a/ctf/__init__.py +++ b/ctf/__init__.py @@ -21,20 +21,21 @@ def check_tool_version() -> None: - with urllib.request.urlopen( - url="https://api.github.com/repos/nsec/ctf-script/releases/latest" - ) as r: - if r.getcode() != 200: - LOG.debug(r.read().decode()) + try: + r_context = urllib.request.urlopen( + url="https://api.github.com/repos/nsec/ctf-script/releases/latest" + ) + except Exception as e: + LOG.debug(e) + LOG.warning("Could not verify the latest release.") + return + with r_context as r: + try: + latest_version = json.loads(s=r.read().decode())["tag_name"] + except Exception as e: + LOG.debug(e) LOG.error("Could not verify the latest release.") return - else: - try: - latest_version = json.loads(s=r.read().decode())["tag_name"] - except Exception as e: - LOG.debug(e) - LOG.error("Could not verify the latest release.") - return compare = 0 for current_part, latest_part in zip(