Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly ignore updates when there is no internet #407

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/ephys-link.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
3 changes: 2 additions & 1 deletion src/ephys_link/back_end/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
15 changes: 9 additions & 6 deletions src/ephys_link/util/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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
Expand Down
Loading