From f9a0648ffbc2497a0e35e7ad393e5f929aba39e7 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 5 Nov 2022 19:26:07 +0200 Subject: [PATCH 1/7] Fixed check changelog dates Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++++ README.rst | 1 + requirements.txt | 2 +- setup.cfg | 1 + slpkg/check_updates.py | 8 ++++++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 456376db..e1b5d529 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +4.2.7 - 05/11/2022 +Added: +- python3-dateutil dependency to fix check ChangeLogs dates + 4.2.6 - 03/11/2022 Fixed: - Check for the file ChangeLog.txt diff --git a/README.rst b/README.rst index 6aaca32a..6e16347e 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,7 @@ Requirements SQLAlchemy>=1.4.36 PyYAML>=6.0 + python-dateutil>=2.8.2 Install ------- diff --git a/requirements.txt b/requirements.txt index 5db7bd95..8bd19d54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ SQLAlchemy>=1.4.36 PyYAML>=6.0 - +python-dateutil>=2.8.2 diff --git a/setup.cfg b/setup.cfg index 166f87e1..3e4486c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,7 @@ python_requires = >=3.7 install_requires = SQLAlchemy >= 1.4.36 PyYAML >= 6.0 + python-dateutil >= 2.8.2 include_package_data = True [options.packages.find] diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 1b267544..b87213f7 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -4,6 +4,7 @@ import os import urllib3 +from dateutil import parser from dataclasses import dataclass from slpkg.configs import Configs @@ -22,13 +23,16 @@ class CheckUpdates: if os.path.isfile(local_chg_txt): with open(local_chg_txt, 'r', encoding='utf-8') as f: - local_date = f.readline().strip() + ldate = f.readline().strip() http = urllib3.PoolManager() repo = http.request( 'GET', f'{self.sbo_repo_url}/{self.chglog_txt}') - repo_date = repo.data.decode().split('\\')[0][:len(local_date)].strip() + rdate = repo.data.decode().split('\\')[0][:len(ldate)].strip() + + repo_date = parser.parse(rdate) + local_date = parser.parse(ldate) if repo_date > local_date: print('\nThere are new updates available.\n') From abdc4bbf833194184dfa29e76cae0f57b2fbec28 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 5 Nov 2022 19:27:26 +0200 Subject: [PATCH 2/7] Updated for version 4.2.7 Signed-off-by: Dimitris Zlatanidis --- README.rst | 4 ++-- setup.cfg | 2 +- slpkg/version.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 6e16347e..63d7a199 100644 --- a/README.rst +++ b/README.rst @@ -31,8 +31,8 @@ Install from the official third-party `SBo repository Date: Sat, 5 Nov 2022 19:39:00 +0200 Subject: [PATCH 3/7] Updated checks Signed-off-by: Dimitris Zlatanidis --- slpkg/check_updates.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index b87213f7..512c8bc8 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -23,18 +23,15 @@ class CheckUpdates: if os.path.isfile(local_chg_txt): with open(local_chg_txt, 'r', encoding='utf-8') as f: - ldate = f.readline().strip() + local_date = f.readline().strip() http = urllib3.PoolManager() repo = http.request( 'GET', f'{self.sbo_repo_url}/{self.chglog_txt}') - rdate = repo.data.decode().split('\\')[0][:len(ldate)].strip() + repo_date = repo.data.decode().split('\\')[0][:len(local_date)].strip() - repo_date = parser.parse(rdate) - local_date = parser.parse(ldate) - - if repo_date > local_date: + if parser.parse(repo_date) > parser.parse(local_date): print('\nThere are new updates available.\n') else: print('\nNo updated packages since the last check.\n') From 8424d25463f8ff41736cca2cd874de23ad123eab Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 6 Nov 2022 18:13:45 +0200 Subject: [PATCH 4/7] Switch to check files by size Signed-off-by: Dimitris Zlatanidis --- slpkg/check_updates.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 512c8bc8..52473375 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -4,7 +4,6 @@ import os import urllib3 -from dateutil import parser from dataclasses import dataclass from slpkg.configs import Configs @@ -18,20 +17,19 @@ class CheckUpdates: def updates(self): - local_date = '' + local_date = 0 local_chg_txt = f'{self.sbo_repo_path}/{self.chglog_txt}' - if os.path.isfile(local_chg_txt): - with open(local_chg_txt, 'r', encoding='utf-8') as f: - local_date = f.readline().strip() - http = urllib3.PoolManager() repo = http.request( 'GET', f'{self.sbo_repo_url}/{self.chglog_txt}') - repo_date = repo.data.decode().split('\\')[0][:len(local_date)].strip() + if os.path.isfile(local_chg_txt): + local_date = int(os.stat(local_chg_txt).st_size) - if parser.parse(repo_date) > parser.parse(local_date): + repo_date = int(repo.headers['Content-Length']) + + if repo_date > local_date: print('\nThere are new updates available.\n') else: print('\nNo updated packages since the last check.\n') From f39375d09f794aef140230c48bb7f72abac90494 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 6 Nov 2022 18:16:12 +0200 Subject: [PATCH 5/7] Removed python-dateutil dependency Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++-- README.rst | 1 - requirements.txt | 1 - setup.cfg | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e1b5d529..63039f66 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,6 @@ 4.2.7 - 05/11/2022 -Added: -- python3-dateutil dependency to fix check ChangeLogs dates +Fixed: +- Switch to check ChangeLogs.txt files by size 4.2.6 - 03/11/2022 Fixed: diff --git a/README.rst b/README.rst index 63d7a199..1477ca9b 100644 --- a/README.rst +++ b/README.rst @@ -22,7 +22,6 @@ Requirements SQLAlchemy>=1.4.36 PyYAML>=6.0 - python-dateutil>=2.8.2 Install ------- diff --git a/requirements.txt b/requirements.txt index 8bd19d54..d06364b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ SQLAlchemy>=1.4.36 PyYAML>=6.0 -python-dateutil>=2.8.2 diff --git a/setup.cfg b/setup.cfg index 49e254f8..8d41c2ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,6 @@ python_requires = >=3.7 install_requires = SQLAlchemy >= 1.4.36 PyYAML >= 6.0 - python-dateutil >= 2.8.2 include_package_data = True [options.packages.find] From a1350ce4ecb8614dc6fcf405c89209eeba18b193 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 6 Nov 2022 20:14:51 +0200 Subject: [PATCH 6/7] Change operator Signed-off-by: Dimitris Zlatanidis --- slpkg/check_updates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 52473375..fe34bffc 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -29,7 +29,7 @@ class CheckUpdates: repo_date = int(repo.headers['Content-Length']) - if repo_date > local_date: + if repo_date != local_date: print('\nThere are new updates available.\n') else: print('\nNo updated packages since the last check.\n') From 5f092d0835c5f1357427fd09089a586cb0aa890e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 6 Nov 2022 20:20:05 +0200 Subject: [PATCH 7/7] Updated with f string Signed-off-by: Dimitris Zlatanidis --- slpkg/upgrade.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index a9aa11be..db6547a1 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -25,8 +25,8 @@ class Upgrade: inst_pkg_name = '-'.join(pkg.split('-')[:-3]) if inst_pkg_name in repo_packages: - installed_ver = pkg.replace( - inst_pkg_name + '-', '').split('-')[0] + installed_ver = pkg.replace(f'{inst_pkg_name}-', + '').split('-')[0] repo_ver = SBoQueries(inst_pkg_name).version() if LooseVersion(repo_ver) > LooseVersion(installed_ver):