Merge "Fix ndk.ansi for Windows."
diff --git a/ndk/ansi.py b/ndk/ansi.py
index 0328938..50719a9 100644
--- a/ndk/ansi.py
+++ b/ndk/ansi.py
@@ -20,7 +20,12 @@
import contextlib
import os
import sys
-import termios
+
+try:
+ import termios
+ HAVE_TERMIOS = True
+except ImportError:
+ HAVE_TERMIOS = False
def cursor_up(lines):
@@ -47,7 +52,7 @@
@contextlib.contextmanager
def disable_terminal_echo(fd):
- if fd.isatty():
+ if HAVE_TERMIOS and fd.isatty():
original = termios.tcgetattr(fd)
termattr = termios.tcgetattr(fd)
termattr[3] &= ~termios.ECHO