summaryrefslogtreecommitdiff
path: root/pykolab/utils.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-05 16:10:23 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-05 16:10:23 (GMT)
commitb3ff42571c0edab8e5b3c064ba3a488a1b534bab (patch)
tree52c7d386c6cf94ef4731cb47c7a0bedde76189c0 /pykolab/utils.py
parent0d0a51065a6780dc40c21ff4250f6cb6b7db7896 (diff)
downloadpykolab-b3ff42571c0edab8e5b3c064ba3a488a1b534bab.tar.gz
Truly remove any buffering that may exist
Diffstat (limited to 'pykolab/utils.py')
-rw-r--r--pykolab/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py
index 63aacb7..c40b252 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -35,6 +35,11 @@ def ask_question(question, default="", password=False):
Usage: pykolab.utils.ask_question("What is the server?", default="localhost")
"""
+
+ # Remove any buffering that may exist
+ sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+
if password:
if default == "":
answer = getpass.getpass("%s: " % (question))
@@ -46,9 +51,6 @@ def ask_question(question, default="", password=False):
else:
answer = raw_input("%s [%s]: " % (question, default))
- sys.stderr.flush()
- sys.stdout.flush()
-
if answer == "":
return default
else:
@@ -61,6 +63,10 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
"yes" or "no", or take the default or any YyNn answer.
"""
+ # Remove any buffering that may exist
+ sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+
if default in [ "y", "Y" ]:
default_answer = True
default_no = "n"
@@ -94,7 +100,6 @@ def ask_confirmation(question, default="y", all_inclusive_no=True):
else:
answer = False
print >> sys.stderr, _("Please answer 'yes' or 'no'.")
- sys.stderr.flush()
def generate_password():
import subprocess