Skip to content

Commit

Permalink
Change latest version URL to real site URL (#104)
Browse files Browse the repository at this point in the history
* Change latest version URL to real site URL

* Use enum
  • Loading branch information
timmo001 authored Apr 7, 2024
1 parent 7e2f3f8 commit ce5c739
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions systembridgebackend/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __init__(self) -> None:

# Get the version
self._version: str | None = None
if self._run_mode == "python":
if self._run_mode == RunMode.PYTHON:
self._version = __version__.public()
if self._run_mode == "standalone":
if self._run_mode == RunMode.STANDALONE:
# Read the version file from the package
with open(
os.path.join(
Expand All @@ -54,7 +54,7 @@ def __init__(self) -> None:
self._logger.info("Version: %s", self._version)

# Determine the latest version URL based on the run mode
self._version_latest_url = f"https://api.github.com/repos/timmo001/{(
self._version_latest_url = f"https://github.com/timmo001/{(
'system-bridge' if self._run_mode == RunMode.STANDALONE else 'system-bridge-backend'
)}/releases/latest"

Expand Down Expand Up @@ -277,15 +277,18 @@ async def _get_version_latest(self) -> Any | None:
self._logger.warning("Rate limit exceeded. Skipping request.")
return self._version_latest

url = f"https://api.github.com/repos/timmo001/{(
'system-bridge' if self._run_mode == RunMode.STANDALONE else 'system-bridge-backend'
)}/releases/latest"
self._logger.debug("GitHub API URL: %s", url)

# Use the GitHub API to get the latest release
self._logger.debug("URL: %s", self._version_latest_url)
async with aiohttp.ClientSession() as session, session.get(
self._version_latest_url
) as response:
async with aiohttp.ClientSession() as session, session.get(url) as response:
if response.status == 200:
data = await response.json()
if data is not None and (tag_name := data.get("tag_name")) is not None:
self._version_latest = tag_name.replace("v", "")
self._logger.info("Latest version: %s", self._version_latest)

return self._version_latest

Expand Down

0 comments on commit ce5c739

Please sign in to comment.