summaryrefslogtreecommitdiff
path: root/pykolab/utils.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-11 15:27:28 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-11 15:27:55 (GMT)
commitbcd2b2fdf90bccd29c281f8143bc9ba73edda01d (patch)
tree0a8f9d8381e83ead69e27c7263cd562ad62971f2 /pykolab/utils.py
parent43cb3e58da39fd7c7566d952691d815488104dd6 (diff)
downloadpykolab-bcd2b2fdf90bccd29c281f8143bc9ba73edda01d.tar.gz
Do not echo passwords back even during confirmation
Diffstat (limited to 'pykolab/utils.py')
-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