Skip to content

Commit

Permalink
Properly ignore updates when there is no internet (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjy5 authored Dec 12, 2024
1 parent c406dd4 commit fde8c6f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
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

0 comments on commit fde8c6f

Please sign in to comment.