mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Updated for check db
This commit is contained in:
parent
3abf09e7d9
commit
3f403e1b07
1 changed files with 15 additions and 22 deletions
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.error_messages import Errors
|
||||
|
@ -19,6 +17,7 @@ class Check(Configs):
|
|||
__slots__ = 'repository', 'data'
|
||||
super(Configs, self).__init__()
|
||||
self.data: dict = data
|
||||
self.repository = repository
|
||||
|
||||
self.errors = Errors()
|
||||
self.utils = Utilities()
|
||||
|
@ -28,16 +27,6 @@ class Check(Configs):
|
|||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
slackbuild_tables: dict = {
|
||||
self.repos.sbo_repo_name: SBoTable,
|
||||
self.repos.ponce_repo_name: PonceTable
|
||||
}
|
||||
|
||||
if self.is_binary:
|
||||
self.repo_table = BinariesTable
|
||||
else:
|
||||
self.repo_table = slackbuild_tables[repository]
|
||||
|
||||
def exists_in_the_database(self, packages: list) -> None:
|
||||
""" Checking if the slackbuild exists in the database. """
|
||||
not_packages: list = []
|
||||
|
@ -82,15 +71,19 @@ class Check(Configs):
|
|||
|
||||
def is_empty_database(self, repo: str) -> None:
|
||||
""" Checking for empty table and database file. """
|
||||
db = Path(self.db_path, self.database_name)
|
||||
sbo_table: dict = {
|
||||
self.repos.sbo_repo_name: SBoTable,
|
||||
self.repos.ponce_repo_name: PonceTable
|
||||
}
|
||||
|
||||
if self.is_binary and repo != '*':
|
||||
count: int = self.session.query(self.repo_table.id).where(self.repo_table.repo == repo).count()
|
||||
else:
|
||||
count: int = self.session.query(self.repo_table.id).count()
|
||||
if repo != '*':
|
||||
if self.is_binary:
|
||||
count: int = self.session.query(BinariesTable.id).where(BinariesTable.repo == repo).count()
|
||||
else:
|
||||
count: int = self.session.query(sbo_table[self.repository].id).count()
|
||||
|
||||
if not self.session.query(self.repo_table).first() or not db.is_file() or count == 0:
|
||||
self.errors.raise_error_message("You need to update the package lists first, run:\n\n"
|
||||
" $ slpkg update\n"
|
||||
" $ slpkg update --bin-repo=[repo_name] for binaries",
|
||||
exit_status=1)
|
||||
if count == 0:
|
||||
self.errors.raise_error_message("You need to update the package lists first, run:\n\n"
|
||||
" $ slpkg update\n"
|
||||
" $ slpkg update --bin-repo=[repo_name] for binaries",
|
||||
exit_status=1)
|
||||
|
|
Loading…
Add table
Reference in a new issue