Python termios 模块,CINTR 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用termios.CINTR

项目:watchmen    作者:lycclsltt    | 项目源码 | 文件源码
def _make_eof_intr():
    """Set constants _EOF and _INTR.

    This avoids doing potentially costly operations on module load.
    """
    global _EOF, _INTR
    if (_EOF is not None) and (_INTR is not None):
        return

    # inherit EOF and INTR definitions from controlling process.
    try:
        from termios import VEOF, VINTR
        try:
            fd = sys.__stdin__.fileno()
        except ValueError:
            # ValueError: I/O operation on closed file
            fd = sys.__stdout__.fileno()
        intr = ord(termios.tcgetattr(fd)[6][VINTR])
        eof = ord(termios.tcgetattr(fd)[6][VEOF])
    except (ImportError, OSError, IOError, ValueError, termios.error):
        # unless the controlling process is also not a terminal,
        # such as cron(1), or when stdin and stdout are both closed.
        # Fall-back to using CEOF and CINTR. There
        try:
            from termios import CEOF, CINTR
            (intr, eof) = (CINTR, CEOF)
        except ImportError:
            #                         ^C, ^D
            (intr, eof) = (3, 4)

    _INTR = _byte(intr)
    _EOF = _byte(eof)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def _make_eof_intr():
    """Set constants _EOF and _INTR.

    This avoids doing potentially costly operations on module load.
    """
    global _EOF, _INTR
    if (_EOF is not None) and (_INTR is not None):
        return

    # inherit EOF and INTR definitions from controlling process.
    try:
        from termios import VEOF, VINTR
        try:
            fd = sys.__stdin__.fileno()
        except ValueError:
            # ValueError: I/O operation on closed file
            fd = sys.__stdout__.fileno()
        intr = ord(termios.tcgetattr(fd)[6][VINTR])
        eof = ord(termios.tcgetattr(fd)[6][VEOF])
    except (ImportError, OSError, IOError, ValueError, termios.error):
        # unless the controlling process is also not a terminal,
        # such as cron(1), or when stdin and stdout are both closed.
        # Fall-back to using CEOF and CINTR. There
        try:
            from termios import CEOF, CINTR
            (intr, eof) = (CINTR, CEOF)
        except ImportError:
            #                         ^C, ^D
            (intr, eof) = (3, 4)

    _INTR = _byte(intr)
    _EOF = _byte(eof)
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def _make_eof_intr():
    """Set constants _EOF and _INTR.

    This avoids doing potentially costly operations on module load.
    """
    global _EOF, _INTR
    if (_EOF is not None) and (_INTR is not None):
        return

    # inherit EOF and INTR definitions from controlling process.
    try:
        from termios import VEOF, VINTR
        try:
            fd = sys.__stdin__.fileno()
        except ValueError:
            # ValueError: I/O operation on closed file
            fd = sys.__stdout__.fileno()
        intr = ord(termios.tcgetattr(fd)[6][VINTR])
        eof = ord(termios.tcgetattr(fd)[6][VEOF])
    except (ImportError, OSError, IOError, ValueError, termios.error):
        # unless the controlling process is also not a terminal,
        # such as cron(1), or when stdin and stdout are both closed.
        # Fall-back to using CEOF and CINTR. There
        try:
            from termios import CEOF, CINTR
            (intr, eof) = (CINTR, CEOF)
        except ImportError:
            #                         ^C, ^D
            (intr, eof) = (3, 4)

    _INTR = _byte(intr)
    _EOF = _byte(eof)
项目:pipenv    作者:pypa    | 项目源码 | 文件源码
def _make_eof_intr():
    """Set constants _EOF and _INTR.

    This avoids doing potentially costly operations on module load.
    """
    global _EOF, _INTR
    if (_EOF is not None) and (_INTR is not None):
        return

    # inherit EOF and INTR definitions from controlling process.
    try:
        from termios import VEOF, VINTR
        try:
            fd = sys.__stdin__.fileno()
        except ValueError:
            # ValueError: I/O operation on closed file
            fd = sys.__stdout__.fileno()
        intr = ord(termios.tcgetattr(fd)[6][VINTR])
        eof = ord(termios.tcgetattr(fd)[6][VEOF])
    except (ImportError, OSError, IOError, ValueError, termios.error):
        # unless the controlling process is also not a terminal,
        # such as cron(1), or when stdin and stdout are both closed.
        # Fall-back to using CEOF and CINTR. There
        try:
            from termios import CEOF, CINTR
            (intr, eof) = (CINTR, CEOF)
        except ImportError:
            #                         ^C, ^D
            (intr, eof) = (3, 4)

    _INTR = _byte(intr)
    _EOF = _byte(eof)
项目:yatta_reader    作者:sound88    | 项目源码 | 文件源码
def _make_eof_intr():
    """Set constants _EOF and _INTR.

    This avoids doing potentially costly operations on module load.
    """
    global _EOF, _INTR
    if (_EOF is not None) and (_INTR is not None):
        return

    # inherit EOF and INTR definitions from controlling process.
    try:
        from termios import VEOF, VINTR
        try:
            fd = sys.__stdin__.fileno()
        except ValueError:
            # ValueError: I/O operation on closed file
            fd = sys.__stdout__.fileno()
        intr = ord(termios.tcgetattr(fd)[6][VINTR])
        eof = ord(termios.tcgetattr(fd)[6][VEOF])
    except (ImportError, OSError, IOError, ValueError, termios.error):
        # unless the controlling process is also not a terminal,
        # such as cron(1), or when stdin and stdout are both closed.
        # Fall-back to using CEOF and CINTR. There
        try:
            from termios import CEOF, CINTR
            (intr, eof) = (CINTR, CEOF)
        except ImportError:
            #                         ^C, ^D
            (intr, eof) = (3, 4)

    _INTR = _byte(intr)
    _EOF = _byte(eof)