Introduce build-time version reference file to make versioning instantaneous and solid
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This commit is contained in:
co-authored by
arena-agent
parent
9df83e8a11
commit
dec0aebc95
@@ -1,4 +1,4 @@
|
||||
"""Load the Nix-generated config for Sovran_SystemsOS_Hub."""
|
||||
"""Load the Nix-generated config and build-time versions for Sovran_SystemsOS_Hub."""
|
||||
|
||||
import json
|
||||
import os
|
||||
@@ -18,3 +18,23 @@ def load_config() -> dict:
|
||||
return json.load(fh)
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {"refresh_interval": 5, "command_method": "systemctl", "services": []}
|
||||
|
||||
|
||||
def load_versions() -> dict:
|
||||
"""Read the Nix-generated or fallback build-time package versions."""
|
||||
path = os.environ.get("SOVRAN_HUB_VERSIONS")
|
||||
if not path:
|
||||
# Candidate 1: parent folder (same as config.json, typical for Nix layout)
|
||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
candidate1 = os.path.join(parent_dir, "versions.json")
|
||||
if os.path.exists(candidate1):
|
||||
path = candidate1
|
||||
else:
|
||||
# Candidate 2: local package folder (dev folder structure)
|
||||
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "versions.json")
|
||||
|
||||
try:
|
||||
with open(path, "r") as fh:
|
||||
return json.load(fh)
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user