Updated for checks

This commit is contained in:
Dimitris Zlatanidis 2023-05-22 13:24:19 +03:00
parent 5d5e991655
commit dab5391252
2 changed files with 16 additions and 20 deletions

View file

@ -13,9 +13,8 @@ from slpkg.models.models import SBoTable, PonceTable, BinariesTable
class Check(Configs):
""" Some checks before proceed. """
def __init__(self, repository: str, data: dict):
def __init__(self, repository: str):
super(Configs, self).__init__()
self.data: dict = data
self.repository = repository
self.errors = Errors()
@ -31,25 +30,25 @@ class Check(Configs):
self.repos.ponce_repo_name: PonceTable
}
def package_exists_in_the_database(self, packages: list) -> None:
def package_exists_in_the_database(self, packages: list, data: dict) -> None:
not_packages: list = []
for pkg in packages:
if not self.data.get(pkg) and pkg != '*':
if not data.get(pkg) and pkg != '*':
not_packages.append(pkg)
if not_packages:
self.errors.raise_error_message(f"Packages '{', '.join(not_packages)}' does not exists",
exit_status=1)
def is_package_unsupported(self, slackbuilds: list) -> None:
def is_package_unsupported(self, slackbuilds: list, data: dict) -> None:
""" Checking for unsupported slackbuilds. """
for sbo in slackbuilds:
if sbo != '*':
if self.os_arch == 'x86_64' and self.data[sbo]['download64']:
sources: list = self.data[sbo]['download64'].split()
if self.os_arch == 'x86_64' and data[sbo]['download64']:
sources: list = data[sbo]['download64'].split()
else:
sources: list = self.data[sbo]['download'].split()
sources: list = data[sbo]['download'].split()
if 'UNSUPPORTED' in sources:
self.errors.raise_error_message(f"Package '{sbo}' unsupported by arch",

View file

@ -47,7 +47,6 @@ class Argparse(Configs):
self.usage = Usage()
self.form_configs = FormConfigs()
self.repos = Repositories()
self.check = None
self.repository: str = self.repos.default_repository
@ -312,6 +311,7 @@ class Argparse(Configs):
self.check_for_repositories()
self.is_binary: bool = self.utils.is_binary_repo(self.repository)
self.check = Check(self.repository)
logging.basicConfig(filename=LoggingConfig.log_file,
filemode=LoggingConfig.filemode,
@ -345,9 +345,6 @@ class Argparse(Configs):
else:
self.data: dict = SBoQueries(self.repository).repository_data()
# Create object for the checks
self.check = Check(self.repository, self.data)
def invalid_options(self) -> None:
""" Checks for invalid options. """
invalid, commands, repeat = [], [], []
@ -631,8 +628,8 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.is_package_unsupported(packages)
self.check.package_exists_in_the_database(packages, self.data)
self.check.is_package_unsupported(packages, self.data)
if self.repository in list(self.repos.repositories.keys())[:2]:
build = Slackbuilds(
@ -659,13 +656,13 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.package_exists_in_the_database(packages, self.data)
if self.is_binary:
install = Packages(self.repository, self.data, packages, self.flags, mode=command)
install.execute()
else:
self.check.is_package_unsupported(packages)
self.check.is_package_unsupported(packages, self.data)
install = Slackbuilds(self.repository, self.data, packages, self.flags, mode=command)
install.execute()
raise SystemExit()
@ -685,7 +682,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.package_exists_in_the_database(packages, self.data)
down_only = DownloadOnly(self.directory, self.flags, self.data, self.repository)
down_only.packages(packages)
raise SystemExit()
@ -740,7 +737,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.package_exists_in_the_database(packages, self.data)
view = ViewPackage(self.flags, self.repository)
@ -784,7 +781,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.package_exists_in_the_database(packages, self.data)
dependees = Dependees(self.data, packages, self.flags, self.repository)
dependees.find()
@ -805,7 +802,7 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
packages: list = self.choose_packages(packages, command)
self.check.package_exists_in_the_database(packages)
self.check.package_exists_in_the_database(packages, self.data)
tracking = Tracking(self.data, packages, self.flags, self.repository)
tracking.package()