From f7ca405716b1ee8b92a940e07cd611f6b025795d Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Mon, 21 Jul 2008 12:25:37 +0200 Subject: Wrap up the raw_input() to user_input() for convenience and uniformity. --- ipa-client/ipa-install/ipa-client-install | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'ipa-client') diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install index ecdf92740..eec36e4e3 100644 --- a/ipa-client/ipa-install/ipa-client-install +++ b/ipa-client/ipa-install/ipa-client-install @@ -30,7 +30,7 @@ try: import ipaclient.ipadiscovery import ipaclient.ipachangeconf import ipaclient.ntpconf - from ipa.ipautil import run + from ipa.ipautil import run, user_input from ipa import sysrestore from ipa import version except ImportError: @@ -70,13 +70,6 @@ def parse_options(): return options -def ask_for_confirmation(message): - yesno = raw_input(message + " [y/N]: ") - if not yesno or yesno.lower()[0] != "y": - return False - print "\n" - return True - def logging_setup(options): # Always log everything (i.e., DEBUG) to the log # file. @@ -124,7 +117,7 @@ def uninstall(options): print "The original nsswitch.conf configuration has been restored." print "You may need to restart services or reboot the machine." if not options.on_master: - if ask_for_confirmation("Do you want to reboot the machine?"): + if user_input("Do you want to reboot the machine?", False): try: run(["/usr/bin/reboot"]) except Exception, e: @@ -163,9 +156,7 @@ def main(): return ret else: print "DNS discovery failed to determine your DNS domain" - cli_domain = "" - while cli_domain == "": - cli_domain = raw_input("Please provide the domain name of your IPA server (ex: example.com): ") + cli_domain = user_input("Please provide the domain name of your IPA server (ex: example.com)", allow_empty = False) ret = ds.search(domain=cli_domain, server=options.server) if not cli_domain: if ds.getDomainName(): @@ -180,9 +171,7 @@ def main(): return ret else: print "DNS discovery failed to find the IPA Server" - cli_server = "" - while cli_server == "": - cli_server = raw_input("Please provide your IPA server name (ex: ipa.example.com): ") + cli_server = user_input("Please provide your IPA server name (ex: ipa.example.com)", allow_empty = False) ret = ds.search(domain=cli_domain, server=cli_server) if not cli_server: if ds.getServerName(): @@ -203,7 +192,7 @@ def main(): print "If you proceed with the installation, services will be configured to always" print "access the discovered server for all operation and will not fail over to" print "other servers in case of failure.\n" - if not ask_for_confirmation("Do you want to proceed and configure the system with fixed values with no DNS discovery?"): + if not user_input("Do you want to proceed and configure the system with fixed values with no DNS discovery?", False): return ret if options.realm_name and options.realm_name != ds.getRealmName(): @@ -220,7 +209,7 @@ def main(): print "BaseDN: "+cli_basedn print "\n" - if not options.unattended and not ask_for_confirmation("Continue to configure the system with these values?"): + if not options.unattended and not user_input("Continue to configure the system with these values?", False): return 1 # Configure ipa.conf -- cgit