utils: add support for package version retreival

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-02-09 12:17:30 -05:00
parent a3121775fc
commit f48c18bfda
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 9 additions and 2 deletions

View File

@ -87,8 +87,15 @@ def retrieve_git_version(source_path: str) -> str:
return f"t{tag}-g{ver}-shallow"
def get_software_version() -> str:
version = "?"
version: str = "?"
try:
import moonraker.__version__ as ver # type: ignore
version = ver.__version__
except Exception:
pass
else:
if version:
return version
try:
version = retrieve_git_version(MOONRAKER_PATH)
except Exception: