Updated for logging

This commit is contained in:
Dimitris Zlatanidis 2023-03-28 17:08:54 +03:00
parent 282f70d2c7
commit cfa2cb7327
2 changed files with 29 additions and 2 deletions

View file

@ -16,6 +16,8 @@ from slpkg.progress_bar import ProgressBar
from slpkg.repositories import Repositories
from slpkg.binaries.required import Required
from slpkg.binaries.queries import BinQueries
from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session
class Packages(Configs):
@ -33,6 +35,7 @@ class Packages(Configs):
self.repos = Repositories()
self.dialogbox = DialogBox()
self.view_message = ViewMessage(self.flags)
self.session = Session
self.output: int = 0
self.stderr = None
@ -53,6 +56,7 @@ class Packages(Configs):
self.flag_reinstall: list = ['-r', '--reinstall']
self.flag_skip_installed: list = ['-k', '--skip-installed']
self.flag_no_silent: list = ['-n', '--no-silent']
self.flag_resolve_off: list = ['-o', '--resolve-off']
self.repo_package_names: list = BinQueries('', self.repo).all_package_names()
@ -130,8 +134,31 @@ class Packages(Configs):
for package in self.binary_packages:
self.process_message: str = f"package '{package}' to install"
command: str = f'{slack_command} {self.tmp_slpkg}/{package}'
self.multi_process(command, package, message)
name: str = self.utils.split_binary_pkg(package[:-4])[0]
self.logging_installed_dependencies(name)
def logging_installed_dependencies(self, name: str) -> None:
""" Logging installed dependencies and used for remove. """
exist = self.session.query(LogsDependencies.name).filter(
LogsDependencies.name == name).first()
requires: list = Required(name, self.repo).resolve()
# Update the dependencies if exist else create it.
if exist:
self.session.query(
LogsDependencies).filter(
LogsDependencies.name == name).update(
{LogsDependencies.requires: ' '.join(requires)})
elif requires:
deps: list = LogsDependencies(name=name, requires=' '.join(requires))
self.session.add(deps)
self.session.commit()
def skip_installed_package(self, package) -> bool:
""" Skip installed package when the option --skip-installed is applied. """
return (self.utils.is_package_installed(package) and not self.utils.is_option(self.flag_reinstall, self.flags)

View file

@ -15,12 +15,12 @@ from slpkg.checksum import Md5sum
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.dialog_box import DialogBox
from slpkg.sbos.dependencies import Requires
from slpkg.downloader import Downloader
from slpkg.views.views import ViewMessage
from slpkg.sbos.queries import SBoQueries
from slpkg.progress_bar import ProgressBar
from slpkg.repositories import Repositories
from slpkg.sbos.dependencies import Requires
from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session
@ -231,7 +231,7 @@ class Slackbuilds(Configs):
def logging_installed_dependencies(self, name: str) -> None:
""" Logging installed dependencies and used for remove. """
exist = self.session.query(LogsDependencies.name).filter( # type: ignore
exist = self.session.query(LogsDependencies.name).filter(
LogsDependencies.name == name).first()
requires: list = Requires(name).resolve()