summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2011-03-24 13:00:59 +0000
committerKaren Tracey <kmtracey@gmail.com>2011-03-24 13:00:59 +0000
commit1dc518555b137beb7b3ffabc8d0e68edd2b27e61 (patch)
treed6f4d12803a084175c8362dc73627a4ae83c2600
parentc5b476e22ac58bd927f9aa12b12976b76400c4b9 (diff)
[1.2.X] Ensure stdin is a tty before handing it to termios, so as to prevent prolems when running under IDEs.
r15911 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15912 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/autoreload.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index e5a421e586..ffa75e2c4f 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -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()