mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-05 11:02:14 +01:00
Fixed for empty db
This commit is contained in:
parent
f3f32ac293
commit
e1be676dff
1 changed files with 20 additions and 15 deletions
|
@ -9,33 +9,38 @@ from slpkg.blacklist import Blacklist
|
|||
from slpkg.utilities import Utilities
|
||||
from slpkg.repositories import Repositories
|
||||
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable, BinariesTable
|
||||
|
||||
|
||||
class Check(Configs):
|
||||
""" Some checks before proceed. """
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.black = Blacklist()
|
||||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
|
||||
self.repo_path = self.repos.sbo_repo_path
|
||||
if self.repos.ponce_repo:
|
||||
self.repo_path = self.repos.ponce_repo_path
|
||||
self.session = Session
|
||||
self.flag_binary: list = ['-B', '--binary']
|
||||
|
||||
def exists_in_the_database(self, slackbuilds: list) -> None:
|
||||
if self.utils.is_option(self.flag_binary, self.flags):
|
||||
self.repo_table = BinariesTable
|
||||
else:
|
||||
self.repo_table = SBoTable
|
||||
if self.repos.ponce_repo:
|
||||
self.repo_table = PonceTable
|
||||
|
||||
def exists_in_the_database(self, packages: list) -> None:
|
||||
""" Checking if the slackbuild exists in the database. """
|
||||
not_packages: list = []
|
||||
|
||||
for sbo in slackbuilds:
|
||||
for pkg in packages:
|
||||
|
||||
if not SBoQueries(sbo).slackbuild():
|
||||
not_packages.append(sbo)
|
||||
|
||||
else:
|
||||
location = SBoQueries(sbo).location()
|
||||
if not Path(self.repo_path, location, sbo).is_dir():
|
||||
not_packages.append(sbo)
|
||||
if not self.session.query(self.repo_table).filter(self.repo_table.name == pkg).first():
|
||||
not_packages.append(pkg)
|
||||
|
||||
if not_packages:
|
||||
self.utils.raise_error_message(f"Packages '{', '.join(not_packages)}' does not exists")
|
||||
|
@ -72,8 +77,8 @@ class Check(Configs):
|
|||
self.utils.raise_error_message(f"The packages '{', '.join(blacklist)}' is blacklisted")
|
||||
|
||||
def is_empty_database(self) -> None:
|
||||
""" Checking for empty table """
|
||||
""" Checking for empty table and database file. """
|
||||
db = Path(self.db_path, self.database_name)
|
||||
if not SBoQueries('').sbos() or not db.is_file():
|
||||
if not self.session.query(self.repo_table).first() or not db.is_file():
|
||||
self.utils.raise_error_message("You need to update the package lists first.\n"
|
||||
" Please run 'slpkg update'")
|
||||
|
|
Loading…
Reference in a new issue