From 36a6f444c4564e6129a8691c0ce4608e5fdb4588 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 6 Mar 2023 21:04:44 +0200 Subject: [PATCH] Updated for clean data --- man/slpkg.1 | 4 ++-- slpkg/update_repository.py | 21 +++++++++++++-------- slpkg/views/cli_menu.py | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index c1a2e613..c7f591f4 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -47,8 +47,8 @@ Deletes all the downloaded SlackBuilds scripts and sources. .P .B -T, clean-data .RS -Sometimes is necessary to clean all the data from the database. -Run this command to drop all the tables from the database and run '\fIslpkg update\fR' to recreate. +Sometimes is necessary to clean all the repositories data from the database. +Run this command to delete all the data and run '\fIslpkg update\fR' to recreate. .RE .P .B -g, configs diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index ff9f4b63..cee5b20b 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -27,18 +27,18 @@ class UpdateRepository(Configs, Utilities): self.flags: list = flags self.session = Session + self.view = ViewMessage(self.flags) self.progress = ProgressBar() self.color = self.colour() self.endc: str = self.color['endc'] self.flag_generate: list = ['-G', '--generate-only'] + self.flag_drop_all: list = ['-A', '--drop-all'] def sbo(self) -> None: """ Updated the sbo repository. """ - view = ViewMessage(self.flags) - - view.question() + self.view.question() if self.ponce_repo: @@ -125,9 +125,14 @@ class UpdateRepository(Configs, Utilities): self.session.query(SBoTable).delete() self.session.commit() - @staticmethod - def drop_the_tables(): + def drop_the_tables(self): """ Drop all the tables from the database. """ - Base.metadata.drop_all(bind=engine, tables=[PonceTable.__table__, - SBoTable.__table__, - LogsDependencies.__table__]) + print('All the data from the database will be deleted.') + self.view.question() + + tables: list = [PonceTable.__table__, + SBoTable.__table__] + + Base.metadata.drop_all(bind=engine, tables=tables) + + print("Successfully cleared!\n\nYou need to run 'slpkg update' now.") diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 6217a579..66d276d6 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -48,7 +48,7 @@ class Usage(Configs): f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n' f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n' f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n' - f' {self.cyan}-T, clean-data{self.endc} Clean all the data from the database.\n' + f' {self.cyan}-T, clean-data{self.endc} Clean all the repositories data.\n' f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n' f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n' f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n'