Ensure stdin is a tty before handing it to termios, so as to prevent prolems when running under IDEs.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15911 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey 2011-03-24 12:36:33 +00:00
parent f3f1983f30
commit 3e7ce3c750
1 changed files with 6 additions and 5 deletions

View File

@ -73,11 +73,12 @@ def code_changed():
def ensure_echo_on():
if termios:
fd = sys.stdin.fileno()
attr_list = termios.tcgetattr(fd)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, attr_list)
fd = sys.stdin
if fd.isatty():
attr_list = termios.tcgetattr(fd)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, attr_list)
def reloader_thread():
ensure_echo_on()