mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Updated check & update
This commit is contained in:
parent
8b518268a6
commit
81daeac381
2 changed files with 21 additions and 19 deletions
|
@ -9,6 +9,7 @@ from urllib3.exceptions import HTTPError
|
|||
from urllib3 import PoolManager, ProxyManager, make_headers
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.repo_info import RepoInfo
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.repositories import Repositories
|
||||
|
@ -26,6 +27,7 @@ class CheckUpdates(Configs):
|
|||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.repos = Repositories()
|
||||
self.repo_info = RepoInfo(flags, repository)
|
||||
|
||||
self.compare: dict = {}
|
||||
|
||||
|
@ -135,16 +137,25 @@ class CheckUpdates(Configs):
|
|||
|
||||
def check_for_updates(self) -> None:
|
||||
self.check_the_repositories()
|
||||
self.view_messages()
|
||||
self.view_messages(self.compare)
|
||||
|
||||
def view_messages(self) -> None:
|
||||
def view_messages(self, compare: dict) -> None:
|
||||
print()
|
||||
for repo, comp in self.compare.items():
|
||||
repo_for_update: list = []
|
||||
for repo, comp in compare.items():
|
||||
if comp:
|
||||
print(f"\n{self.endc}There are new updates available for the "
|
||||
f"'{self.bgreen}{repo}{self.endc}' repository!")
|
||||
repo_for_update.append(repo)
|
||||
|
||||
if True not in self.compare.values():
|
||||
if repo_for_update:
|
||||
print(f"\n{self.endc}There are new updates available for the "
|
||||
f"repositories: \n")
|
||||
for repo in repo_for_update:
|
||||
repo_length: int = max(len(name) for name in repo_for_update)
|
||||
print(f'> {self.bgreen}{repo:<{repo_length}}{self.endc} Last Updated: '
|
||||
f"'{self.repo_info.last_repository_updated(repo)}'")
|
||||
|
||||
# if True not in self.compare.values():
|
||||
if not any(list(compare.values())):
|
||||
print(f'\n{self.endc}{self.yellow}No updated packages since the last check.{self.endc}')
|
||||
|
||||
def updates(self) -> None:
|
||||
|
|
|
@ -5,9 +5,10 @@ from pathlib import Path
|
|||
from multiprocessing import Process, Queue
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.views import View
|
||||
from slpkg.repo_info import RepoInfo
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.views.views import View
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.install_data import InstallData
|
||||
from slpkg.repositories import Repositories
|
||||
|
@ -37,6 +38,7 @@ class UpdateRepositories(Configs):
|
|||
self.generate = SBoGenerate()
|
||||
self.check_updates = CheckUpdates(flags, repository)
|
||||
self.download = Downloader(flags)
|
||||
self.repo_info = RepoInfo(flags, repository)
|
||||
|
||||
self.repos_for_update: dict = {}
|
||||
|
||||
|
@ -696,21 +698,10 @@ class UpdateRepositories(Configs):
|
|||
|
||||
def check_for_updates(self, queue) -> dict:
|
||||
compare: dict = self.check_updates.check_the_repositories()
|
||||
self.print_the_messages(compare)
|
||||
self.check_updates.view_messages(compare)
|
||||
|
||||
return queue.put(compare)
|
||||
|
||||
def print_the_messages(self, compare: dict) -> None:
|
||||
print()
|
||||
for repo, comp in compare.items():
|
||||
if comp:
|
||||
print(f"\n{self.endc}There are new updates available for the "
|
||||
f"'{self.bgreen}{repo}{self.endc}' repository!")
|
||||
|
||||
if not any(list(compare.values())):
|
||||
print(f'\n{self.endc}{self.yellow}No changes in ChangeLog.txt between your '
|
||||
f'last update and now.{self.endc}')
|
||||
|
||||
def repositories(self) -> None:
|
||||
queue = Queue()
|
||||
message: str = 'Checking for news, please wait...'
|
||||
|
|
Loading…
Reference in a new issue