From fde8c6f172c290b659cacc9571848f57b4595a27 Mon Sep 17 00:00:00 2001 From: Kenneth Yang <82800265+kjy5@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:07:22 -0800 Subject: [PATCH] Properly ignore updates when there is no internet (#407) --- .idea/ephys-link.iml | 2 +- .idea/misc.xml | 2 +- pyproject.toml | 3 --- src/ephys_link/back_end/server.py | 3 ++- src/ephys_link/util/common.py | 15 +++++++++------ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.idea/ephys-link.iml b/.idea/ephys-link.iml index 61e1d8e..078e915 100644 --- a/.idea/ephys-link.iml +++ b/.idea/ephys-link.iml @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7b1598c..e63ad80 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/pyproject.toml b/pyproject.toml index 7d73fef..826f903 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,9 +75,6 @@ dependencies = [ # "cov-report", #] -#[[tool.hatch.envs.all.matrix]] -#python = ["3.8", "3.9", "3.10", "3.11", "3.12"] - [tool.hatch.envs.exe] python = "3.13" dependencies = [ diff --git a/src/ephys_link/back_end/server.py b/src/ephys_link/back_end/server.py index 9ead2e3..c7d356f 100644 --- a/src/ephys_link/back_end/server.py +++ b/src/ephys_link/back_end/server.py @@ -50,7 +50,8 @@ def launch(self) -> None: server_preamble() # Check for updates. - check_for_updates() + if not self._options.ignore_updates: + check_for_updates() # List platform and available manipulators. self._console.info_print("PLATFORM", self._platform_handler.get_platform_type()) diff --git a/src/ephys_link/util/common.py b/src/ephys_link/util/common.py index d9c7c2f..2fc3aea 100644 --- a/src/ephys_link/util/common.py +++ b/src/ephys_link/util/common.py @@ -5,7 +5,7 @@ from pathlib import Path from packaging.version import parse -from requests import get +from requests import ConnectionError, ConnectTimeout, get from vbl_aquarium.models.unity import Vector4 from ephys_link.__about__ import __version__ @@ -43,11 +43,14 @@ def server_preamble() -> None: def check_for_updates() -> None: """Check for updates to the Ephys Link.""" - response = get("https://api.github.com/repos/VirtualBrainLab/ephys-link/tags", timeout=10) - latest_version = response.json()[0]["name"] - if parse(latest_version) > parse(__version__): - print(f"Update available: {latest_version} !") - print("Download at: https://github.com/VirtualBrainLab/ephys-link/releases/latest") + try: + response = get("https://api.github.com/repos/VirtualBrainLab/ephys-link/tags", timeout=10) + latest_version = response.json()[0]["name"] + if parse(latest_version) > parse(__version__): + print(f"Update available: {latest_version} !") + print("Download at: https://github.com/VirtualBrainLab/ephys-link/releases/latest") + except (ConnectionError, ConnectTimeout): + print("Unable to check for updates. Ignore updates or use the the -i flag to disable checks.\n") # Unit conversions