diff --git a/Makefile b/Makefile index dbbb61c..7dbc913 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,10 @@ db_drop_db_code_generator: db_drop_db_template: ./.venv/bin/python3 ./odoo/odoo-bin db --drop --database template +.PHONY: db_clean_cache +db_clean_cache: + ./script/db_restore.py --clean_cache + .PHONY: db_restore_erplibre_base_db_test db_restore_erplibre_base_db_test: ./script/db_restore.py --database test diff --git a/script/db_restore.py b/script/db_restore.py index 35f5885..e688410 100755 --- a/script/db_restore.py +++ b/script/db_restore.py @@ -60,6 +60,14 @@ def get_master_password(): _logger.error("Password echoed, danger!") +def get_list_db_cache(arg_base): + arg = f"{arg_base} --list" + out = check_output(arg.split(" ")).decode() + lst_db = out.strip().split("\n") + lst_db_cache = [a for a in lst_db if a.startswith("_cache_")] + return lst_db, lst_db_cache + + def main(): config = get_config() @@ -88,10 +96,7 @@ def main(): _logger.info("No master password needed... Continue") # Get list of database - arg = f"{arg_base} --list" - out = check_output(arg.split(" ")).decode() - lst_db = out.strip().split("\n") - lst_db_cache = [a for a in lst_db if a.startswith("_cache_")] + lst_db, lst_db_cache = get_list_db_cache(arg_base) if config.clean_cache: for db in lst_db_cache: @@ -99,6 +104,7 @@ def main(): arg = f"{arg_base} --drop --database {db}" out = check_output(arg.split(" ")).decode() print(out) + lst_db, lst_db_cache = get_list_db_cache(arg_base) if config.database: cache_database = f"_cache_{config.image}"