'Contextmanager that replaces stdout and stdin with /dev/tty
and resets them when it is done.'

@classmethod
@contextlib.contextmanager
def _replaceStdoutStdin(cls):

    (oldout, oldin) = (sys.stdout, sys.stdin)
    (sys.stdin, sys.stdout) = cls._openTty()
    try:
        (yield)
    finally:
        sys.stdout.close()
        sys.stdin.close()
        (sys.stdout, sys.stdin) = (oldout, oldin)
