Skip to content

Commit

Permalink
Merge pull request #11 from adator85/dev
Browse files Browse the repository at this point in the history
convert version string to int
  • Loading branch information
adator85 authored Aug 3, 2024
2 parents de69a1a + 743069f commit 61813e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
48 changes: 25 additions & 23 deletions core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,34 @@ def __get_latest_defender_version(self) -> None:
self.logs.warning(f'Github not available to fetch latest version')

def check_for_new_version(self) -> bool:
try:
# Assigner la version actuelle de Defender
self.__set_current_defender_version()
# Récuperer la dernier version disponible dans github
self.__get_latest_defender_version()

# Assigner la version actuelle de Defender
self.__set_current_defender_version()
# Récuperer la dernier version disponible dans github
self.__get_latest_defender_version()

isNewVersion = False
latest_version = self.LATEST_DEFENDER_VERSION
current_version = self.DEFENDER_VERSION

curr_major, curr_minor, curr_patch = current_version.split('.')
last_major, last_minor, last_patch = latest_version.split('.')

if last_major > curr_major:
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
elif last_major == curr_major and last_minor > curr_minor:
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
elif last_major == curr_major and last_minor == curr_minor and last_patch > curr_patch:
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
else:
isNewVersion = False
latest_version = self.LATEST_DEFENDER_VERSION
current_version = self.DEFENDER_VERSION

curr_major , curr_minor, curr_patch = current_version.split('.')
last_major, last_minor, last_patch = latest_version.split('.')

if int(last_major) > int(curr_major):
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
elif int(last_major) == int(curr_major) and int(last_minor) > int(curr_minor):
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
elif int(last_major) == int(curr_major) and int(last_minor) == int(curr_minor) and int(last_patch) > int(curr_patch):
self.logs.info(f'New version available: {current_version} >>> {latest_version}')
isNewVersion = True
else:
isNewVersion = False

return isNewVersion
return isNewVersion
except ValueError as ve:
self.logs.error(f'Impossible to convert in version number : {ve}')

def get_unixtime(self) -> int:
"""
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.0.1"
"version": "4.0.2"
}

0 comments on commit 61813e3

Please sign in to comment.