From 0fd3ffeff59e5782b89de3d9d64da2633a5dcfed Mon Sep 17 00:00:00 2001 From: Bruno Muniz Date: Tue, 5 Sep 2023 11:51:09 -0300 Subject: [PATCH] Small parser argument fix Additional changes were necessary. Now it's possible to use either -y or --yes-to-all to get a 'y' answers on all yes/no questions. The result of the parser is explicitly stored on a variable called 'y' on the namespace that the argparse returns. Task: 48626 Story: 2005051 Change-Id: I4760ea2f1f77bee7c11cf7e0e76ee2566f383b19 --- virtualbox/pybox/Parser.py | 2 +- virtualbox/pybox/install_vbox.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/virtualbox/pybox/Parser.py b/virtualbox/pybox/Parser.py index 06e10d1..5cd520b 100644 --- a/virtualbox/pybox/Parser.py +++ b/virtualbox/pybox/Parser.py @@ -314,7 +314,7 @@ def parse_networking(parser: ArgumentParser): """, type=str, default='32000') - parser.add_argument("-y", "--yes-to-all", help= + parser.add_argument("-y", "--yes-to-all", dest="y", help= """ Automatically answers all yes/no prompts with yes. """, diff --git a/virtualbox/pybox/install_vbox.py b/virtualbox/pybox/install_vbox.py index 91fd376..11f53bd 100755 --- a/virtualbox/pybox/install_vbox.py +++ b/virtualbox/pybox/install_vbox.py @@ -284,9 +284,11 @@ def yes_no_prompt(message): Returns: Answer to the prompt(bool) """ - if V_BOX_OPTIONS.y == True: + question = message + " (y/n)" + if V_BOX_OPTIONS.y is True: + LOG.info("Automatically answering 'y' to '%s'", question) return True - LOG.info("%s (y/n)",message) + LOG.info("%s", question) choice = input().lower() if choice == 'y': return True @@ -331,7 +333,7 @@ def create_port_forward(hostname, network, local_port, guest_port, guest_ip): ) else: LOG.info("Ignoring the creation of the port-forward rule and continuing installation!") - + # pylint: disable=too-many-locals, too-many-branches, too-many-statements