From 622b20fd11b3afb95e9b4630375eebf6a7504713 Mon Sep 17 00:00:00 2001 From: Savely Krendelhoff Date: Mon, 17 Jul 2023 13:40:30 +0300 Subject: [PATCH] [Chore] Unify interactive queries in tezos-setup Problem: Some interactive queries use step concept, while others are done through `yes_or_no`. It's useful to unify them by using steps only for logging and for the #568 (non-interactive mode) issue. Solution: Rewrite delete node data query using steps instead of `yes_or_no`. --- docker/package/tezos_setup_wizard.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docker/package/tezos_setup_wizard.py b/docker/package/tezos_setup_wizard.py index 14eb89c8e..fdf62395a 100644 --- a/docker/package/tezos_setup_wizard.py +++ b/docker/package/tezos_setup_wizard.py @@ -160,6 +160,20 @@ def get_snapshot_mode_query(modes): ) +delete_node_data_options = { + "No": "Keep the existing data", + "Yes": "Remove the data under the tezos node data directory", +} + +delele_node_data_query = Step( + id="delete_node_data", + prompt="Delete this data and bootstrap the node again?", + help="It's possible to proceed with bootstrapping the node using\n" + "the existing blockchain data, instead of importing fresh snapshot.", + options=delete_node_data_options, + validator=Validator(enum_range_validator(delete_node_data_options)), +) + snapshot_file_query = Step( id="snapshot_file", prompt="Provide the path to the node snapshot file.", @@ -239,7 +253,8 @@ def check_blockchain_data(self): if diff: print("The Tezos node data directory already has some blockchain data:") print("\n".join(["- " + os.path.join(node_dir, path) for path in diff])) - if yes_or_no("Delete this data and bootstrap the node again? ", "no"): + self.query_step(delele_node_data_query) + if self.config["delete_node_data"] == "Yes": # We first stop the node service, because it's possible that it # will re-create some of the files while we go on with the wizard print("Stopping node service")