mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-13 20:01:48 +01:00
Updated for checks
This commit is contained in:
parent
e116ecdc5b
commit
caf29d6262
1 changed files with 26 additions and 20 deletions
|
@ -23,9 +23,14 @@ class Check(Configs):
|
|||
self.repos = Repositories()
|
||||
|
||||
self.session = Session
|
||||
|
||||
self.count_rows: int = 0
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.sbo_table: dict = {
|
||||
self.repos.sbo_repo_name: SBoTable,
|
||||
self.repos.ponce_repo_name: PonceTable
|
||||
}
|
||||
|
||||
def package_exists_in_the_database(self, packages: list) -> None:
|
||||
not_packages: list = []
|
||||
|
||||
|
@ -64,26 +69,27 @@ class Check(Configs):
|
|||
|
||||
def is_database_empty(self) -> None:
|
||||
""" Checking for empty table and database file. """
|
||||
count: int = 0
|
||||
sbo_table: dict = {
|
||||
self.repos.sbo_repo_name: SBoTable,
|
||||
self.repos.ponce_repo_name: PonceTable
|
||||
}
|
||||
|
||||
if self.repository == '*':
|
||||
for repository, item in self.repos.repositories.items():
|
||||
if item['path']:
|
||||
if self.utils.is_binary_repo(repository):
|
||||
count += self.session.query(BinariesTable.id).where(
|
||||
BinariesTable.repo == repository).count()
|
||||
else:
|
||||
count += self.session.query(sbo_table[repository].id).count()
|
||||
self.count_of_repositories()
|
||||
else:
|
||||
if self.is_binary:
|
||||
count: int = self.session.query(BinariesTable.id).where(BinariesTable.repo == self.repository).count()
|
||||
else:
|
||||
count: int = self.session.query(sbo_table[self.repository].id).count()
|
||||
self.count_of_repository()
|
||||
|
||||
if count == 0:
|
||||
if self.count_rows == 0:
|
||||
self.errors.raise_error_message("You need to update the package lists first, run:\n\n"
|
||||
" $ slpkg update", exit_status=1)
|
||||
f"{'':>14}$ slpkg update", exit_status=1)
|
||||
|
||||
def count_of_repositories(self):
|
||||
for repository, item in self.repos.repositories.items():
|
||||
if item['path'] and item['enable']:
|
||||
if self.utils.is_binary_repo(repository):
|
||||
self.count_rows += self.session.query(BinariesTable.id).where(
|
||||
BinariesTable.repo == repository).count()
|
||||
else:
|
||||
self.count_rows += self.session.query(self.sbo_table[repository].id).count()
|
||||
|
||||
def count_of_repository(self):
|
||||
if self.is_binary:
|
||||
self.count_rows: int = self.session.query(
|
||||
BinariesTable.id).where(BinariesTable.repo == self.repository).count()
|
||||
else:
|
||||
self.count_rows: int = self.session.query(self.sbo_table[self.repository].id).count()
|
||||
|
|
Loading…
Reference in a new issue