summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-11 16:27:28 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-11 16:27:28 +0100
commit77622e6c45bd64b2a159e1b0768f44f81e9881d8 (patch)
tree4ada7e53560898765070dffb6455898ba6ef3141 /pykolab
parent1154e3c0ed8c06ed0d709dd92e93f30c9055981c (diff)
downloadpykolab-77622e6c45bd64b2a159e1b0768f44f81e9881d8.tar.gz
Do not echo passwords back even during confirmation
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/utils.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py
index 6326bf8..325446f 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -46,23 +46,37 @@ def ask_question(question, default="", password=False, confirm=False):
else:
answer = raw_input("%s [%s]: " % (question, default))
- if not answer == "" and not default == "":
+ if not answer == "":
if confirm:
answer_confirm = None
answer_confirmed = False
while not answer_confirmed:
- if default == "":
- answer_confirm = raw_input("Confirm %s: " % (question))
+ if password:
+ if default == "":
+ answer = getpass.getpass(_("Confirm %s: ") % (question))
+ else:
+ answer = getpass.getpass(_("Confirm %s [%s]: ") % (question, default))
else:
- answer_confirm = raw_input("Confirm %s [%s]: " % (question, default))
+ if default == "":
+ answer = raw_input(_("Confirm %s: ") % (question))
+ else:
+ answer = raw_input(_("Confirm %s [%s]: ") % (question, default))
if not answer_confirm == answer:
print >> sys.stderr, _("Incorrect confirmation. " + \
"Please try again.")
- if default == "":
- answer = raw_input("%s: " % (question))
+
+ if password:
+ if default == "":
+ answer = getpass.getpass(_("Confirm %s: ") % (question))
+ else:
+ answer = getpass.getpass(_("Confirm %s [%s]: ") % (question, default))
else:
- answer = raw_input("%s [%s]: " % (question, default))
+ if default == "":
+ answer = raw_input(_("Confirm %s: ") % (question))
+ else:
+ answer = raw_input(_("Confirm %s [%s]: ") % (question, default))
+
else:
answer_confirmed = True