Skip to content

Commit

Permalink
Now check version only on the major release
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Dec 13, 2024
1 parent 0bc04b6 commit 76884c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jtop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
__copyright__ = "(c) 2024, Raffaello Bonghi"
# Version package
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme
__version__ = "4.2.12"
__version__ = "4.3.0"
# EOF
6 changes: 6 additions & 0 deletions jtop/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def __repr__(self):
return repr(self._data)


def compare_versions(source_version, get_version):
source_major_minor = '.'.join(source_version.split('.')[:2])
get_major_minor = '.'.join(get_version.split('.')[:2])
return source_major_minor == get_major_minor


def check_file(path):
return os.path.isfile(path) and os.access(path, os.R_OK)

Expand Down
5 changes: 3 additions & 2 deletions jtop/jtop.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .core.gpu import GPU
from .core.jetson_clocks import JetsonClocks
from .core.nvpmodel import NVPModel
from .core.common import get_var, get_local_interfaces, status_disk
from .core.common import compare_versions, get_var, get_local_interfaces, status_disk
from .core.jetson_libraries import get_libraries, get_cuda, get_opencv
from .core.exceptions import JtopException
# Fix connection refused for python 2.7
Expand Down Expand Up @@ -1142,7 +1142,8 @@ def start(self):
init = self._get_configuration()
# Get jtop service version
service_version = init.get('version', 'unknown')
if service_version != get_var(VERSION_RE):
# Check version compatibility between client and server raise exception only if minor version is different
if not compare_versions(service_version, get_var(VERSION_RE)):
raise JtopException("""Mismatch version jtop service: [{service_version}] and client: [{client_version}]. Please run:\n
sudo systemctl restart jtop.service""".format(
service_version=service_version,
Expand Down

0 comments on commit 76884c7

Please sign in to comment.