Author: gnichols
Date: 2012-05-16 15:16:57 +0000 (Wed, 16 May 2012)
New Revision: 1308
Modified:
trunk/v7/commandLineUI.py
Log:
818184 - input check is needed for hardware category field
Modified: trunk/v7/commandLineUI.py
===================================================================
--- trunk/v7/commandLineUI.py 2012-05-16 15:15:46 UTC (rev 1307)
+++ trunk/v7/commandLineUI.py 2012-05-16 15:16:57 UTC (rev 1308)
@@ -85,11 +85,16 @@
label += " ("
label += "|".join(answers)
label += ") "
- readline.set_startup_hook(lambda: readline.insert_text(value))
- try:
- return raw_input(label)
- finally:
- readline.set_startup_hook()
+ while True:
+ readline.set_startup_hook(lambda: readline.insert_text(value))
+ try:
+ answer = raw_input(label)
+ if not answers or answer in answers:
+ return answer
+ # otherwise
+ print "Please enter one of the following: %s" % " |
".join(answers)
+ finally:
+ readline.set_startup_hook()
def promptPassword(self, message):
return getpass.getpass(message)
Show replies by date