From f91b62d3d7366ae4eda55a2b9f9da57be4e1bd6a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 16 Jul 2021 04:32:17 -0400 Subject: [PATCH] [FIX] script db_restore: force exit when clean cache database --- Makefile | 4 ++++ script/db_restore.py | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) 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}"