Merge pull request #3482 from aanand/fix-prompt-buffering

Fix bug where confirmation prompt doesn't show due to line buffering
This commit is contained in:
Joffrey F 2016-05-19 08:52:34 -07:00
commit 9a39208741
1 changed files with 11 additions and 1 deletions

View File

@ -6,9 +6,9 @@ import os
import platform import platform
import ssl import ssl
import subprocess import subprocess
import sys
import docker import docker
from six.moves import input
import compose import compose
@ -42,6 +42,16 @@ def yesno(prompt, default=None):
return None return None
def input(prompt):
"""
Version of input (raw_input in Python 2) which forces a flush of sys.stdout
to avoid problems where the prompt fails to appear due to line buffering
"""
sys.stdout.write(prompt)
sys.stdout.flush()
return sys.stdin.readline().rstrip(b'\n')
def call_silently(*args, **kwargs): def call_silently(*args, **kwargs):
""" """
Like subprocess.call(), but redirects stdout and stderr to /dev/null. Like subprocess.call(), but redirects stdout and stderr to /dev/null.