Skip to content

Commit

Permalink
Function for getting current version
Browse files Browse the repository at this point in the history
  • Loading branch information
sdatkinson committed Sep 18, 2024
1 parent 4ceac0d commit 46c3236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions nam/train/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Version utility
"""

from .._version import __version__


class Version:
def __init__(self, major: int, minor: int, patch: int):
Expand Down Expand Up @@ -40,3 +42,7 @@ def __str__(self) -> str:


PROTEUS_VERSION = Version(4, 0, 0)


def get_current_version() -> Version:
return Version.from_string(__version__)
13 changes: 7 additions & 6 deletions nam/train/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Ok private access here--this is technically allowed access
from nam.train import metadata
from nam.train._names import INPUT_BASENAMES, LATEST_VERSION
from nam.train._version import Version
from nam.train._version import Version, get_current_version
from nam.train.metadata import TRAINING_KEY

_install_is_valid = True
Expand Down Expand Up @@ -606,7 +606,7 @@ def update_nam():

self._widgets[_GUIWidgets.UPDATE] = tk.Button(
self._frame_update,
text=f"Update available! {version_from} -> {version_to}",
text=f"Update trainer ({version_from} -> {version_to})",
width=_BUTTON_WIDTH,
height=_BUTTON_HEIGHT,
command=update_nam,
Expand Down Expand Up @@ -642,15 +642,16 @@ def get_info() -> UpdateInfo:
print("No releases found for this repository.")
if latest_version is None:
return
available = latest_version > Version.from_string(__version__)
current_version = get_current_version()
update_available = latest_version > current_version
return UpdateInfo(
available=available,
current_version=__version__,
available=update_available,
current_version=str(current_version),
new_version=str(latest_version),
)

update_info = get_info()
if update_info.available:
if True: # update_info.available:
self._pack_update_button(
update_info.current_version, update_info.new_version
)
Expand Down

0 comments on commit 46c3236

Please sign in to comment.