当前位置: 首页>>代码示例>>Python>>正文


Python termios.ISIG属性代码示例

本文整理汇总了Python中termios.ISIG属性的典型用法代码示例。如果您正苦于以下问题:Python termios.ISIG属性的具体用法?Python termios.ISIG怎么用?Python termios.ISIG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在termios的用法示例。


在下文中一共展示了termios.ISIG属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def init():
    fd = sys.stdin.fileno()
    # save old state
    flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
    attrs_save = termios.tcgetattr(fd)
    # make raw - the way to do this comes from the termios(3) man page.
    attrs = list(attrs_save) # copy the stored version to update
    # iflag
    attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK 
                  | termios.ISTRIP | termios.INLCR | termios. IGNCR 
                  | termios.ICRNL | termios.IXON )
    # oflag
    attrs[1] &= ~termios.OPOST
    # cflag
    attrs[2] &= ~(termios.CSIZE | termios. PARENB)
    attrs[2] |= termios.CS8
    # lflag
    attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON
                  | termios.ISIG | termios.IEXTEN)
    termios.tcsetattr(fd, termios.TCSANOW, attrs)
    # turn off non-blocking
    fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
    # read a single keystroke
    return (flags_save, attrs_save) 
开发者ID:mbechtel2,项目名称:DeepPicar-v2,代码行数:26,代码来源:input_kbd.py

示例2: setup

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def setup(self):
            new = termios.tcgetattr(self.fd)
            new[3] = new[3] & ~termios.ICANON & ~termios.ECHO & ~termios.ISIG
            new[6][termios.VMIN] = 1
            new[6][termios.VTIME] = 0
            termios.tcsetattr(self.fd, termios.TCSANOW, new) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:8,代码来源:miniterm.py

示例3: setup

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def setup(self):
            self.old = termios.tcgetattr(self.fd)
            new = termios.tcgetattr(self.fd)
            new[3] = new[3] & ~termios.ICANON & ~termios.ECHO & ~termios.ISIG
            new[6][termios.VMIN] = 1
            new[6][termios.VTIME] = 0
            termios.tcsetattr(self.fd, termios.TCSANOW, new) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:9,代码来源:miniterm.py

示例4: prepare_tty

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def prepare_tty():                       
    "set the terminal in char mode (return each keyboard press at once) and"\
    " switch off echoing of this input; return the original settings"
    stdin_fd = sys.stdin.fileno()  # will most likely be 0  ;->
    old_stdin_config = termios.tcgetattr(stdin_fd)
    [ iflag, oflag, cflag, lflag, ispeed, ospeed, cc ] = \
        termios.tcgetattr(stdin_fd)
    cc[termios.VTIME] = 1
    cc[termios.VMIN] = 1
    iflag = iflag & ~(termios.IGNBRK |
                      termios.BRKINT |
                      termios.PARMRK |
                      termios.ISTRIP |
                      termios.INLCR |
                      termios.IGNCR |
                      #termios.ICRNL |
                      termios.IXON)
    #  oflag = oflag & ~termios.OPOST
    cflag = cflag | termios.CS8
    lflag = lflag & ~(termios.ECHO |
                      termios.ECHONL |
                      termios.ICANON |
                      # termios.ISIG |
                      termios.IEXTEN)
    termios.tcsetattr(stdin_fd, termios.TCSANOW,
                      [ iflag, oflag, cflag, lflag, ispeed, ospeed, cc ])
    return (stdin_fd, old_stdin_config) 
开发者ID:ActiveState,项目名称:code,代码行数:29,代码来源:recipe-580680.py

示例5: _patch_lflag

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def _patch_lflag(cls, attrs):
        return attrs & ~(termios.ECHO | termios.ICANON | termios.IEXTEN | termios.ISIG) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:4,代码来源:vt100.py

示例6: get_instruction_key

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def get_instruction_key(self):
        """Waits for a single keypress on stdin.

        This is a silly function to call if you need to do it a lot because it has
        to store stdin's current setup, setup stdin for reading single keystrokes
        then read the single keystroke then revert stdin back after reading the
        keystroke.

        Returns the character of the key that was pressed (zero on
        KeyboardInterrupt which can happen when a signal gets handled)

        This method is licensed under cc by-sa 3.0 
        Thanks to mheyman http://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key\
        """
        import termios, fcntl, sys, os
        fd = sys.stdin.fileno()
        # save old state
        flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
        attrs_save = termios.tcgetattr(fd)
        # make raw - the way to do this comes from the termios(3) man page.
        attrs = list(attrs_save) # copy the stored version to update
        # iflag
        attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK 
                      | termios.ISTRIP | termios.INLCR | termios. IGNCR 
                      | termios.ICRNL | termios.IXON )
        # oflag
        attrs[1] &= ~termios.OPOST
        # cflag
        attrs[2] &= ~(termios.CSIZE | termios. PARENB)
        attrs[2] |= termios.CS8
        # lflag
        attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON
                      | termios.ISIG | termios.IEXTEN)
        termios.tcsetattr(fd, termios.TCSANOW, attrs)
        # turn off non-blocking
        fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
        # read a single keystroke
        try:
            ret = sys.stdin.read(1) # returns a single character
        except KeyboardInterrupt:
            ret = 0
        finally:
            # restore old state
            termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save)
            fcntl.fcntl(fd, fcntl.F_SETFL, flags_save)
        return ret 
开发者ID:Azure,项目名称:simdem,代码行数:48,代码来源:cli.py

示例7: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def __init__(self, printer, prot, iomanager):
    self.printer = printer
    self.prot = prot
    self.iomanager = iomanager

    (master_fd, slave_fd) = os.openpty()
    slave = os.ttyname(slave_fd)

    master_flags = fcntl.fcntl(master_fd, fcntl.F_GETFL, 0)
    fcntl.fcntl(master_fd, fcntl.F_SETFL, master_flags | os.O_NONBLOCK)

    # switch to "raw" mode - these constants come from the manpage for termios under cfmakeraw()
    master_attr = termios.tcgetattr(master_fd)
    master_attr[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK | termios.ISTRIP
                        | termios.INLCR | termios.IGNCR | termios.ICRNL | termios.IXON)
    master_attr[1] &= ~termios.OPOST
    master_attr[2] &= ~(termios.CSIZE | termios.PARENB)
    master_attr[3] &= ~(termios.ECHO | termios.ECHONL | termios.ICANON | termios.ISIG
                        | termios.IEXTEN)
    master_attr[3] |= termios.CS8
    termios.tcsetattr(master_fd, termios.TCSADRAIN, master_attr)

    # Fun detail: master will always show as /dev/ptmx, but the kernel knows from
    # the fd which PTY we're using. This means we have to use master_fd instead
    # of opening master by name.

    logging.info("Opened PTY for {} and got {}".format(prot, os.ttyname(slave_fd)))

    self.pipe_link = "/dev/" + prot + "_1"

    try:
      os.unlink(self.pipe_link)
    except OSError as e:
      # file not found is fine to ignore - anythine else and we should log it
      if e.errno != errno.ENOENT:
        logging.error("Failed to unlink '{}': {}".format(self.pipe_link, e.strerror))

    logging.info("linking {}".format(self.pipe_link))
    os.symlink(slave, self.pipe_link)
    os.chmod(self.pipe_link, 0o666)

    logging.info("{} Pipe open. Use '{}' to communicate with it".format(self.prot, self.pipe_link))

    self.rd = os.fdopen(master_fd, "r")
    self.wr = os.fdopen(master_fd, "w")

    self.send_response = True
    self.iomanager.add_file(self.rd, self.get_message) 
开发者ID:intelligent-agent,项目名称:redeem,代码行数:50,代码来源:Pipe.py

示例8: read_single_keypress

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ISIG [as 别名]
def read_single_keypress():
    """Waits for a single keypress on stdin.
    https://stackoverflow.com/a/6599441/1497443

    This is a silly function to call if you need to do it a lot because it has
    to store stdin's current setup, setup stdin for reading single keystrokes
    then read the single keystroke then revert stdin back after reading the
    keystroke.

    Returns the character of the key that was pressed (zero on
    KeyboardInterrupt which can happen when a signal gets handled)

    """
    if fcntl is None or termios is None:
        raise ValueError('termios and/or fcntl packages are not available in your system. This is possible because you are not on a Linux Distro.')
    fd = sys.stdin.fileno()
    # save old state
    flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
    attrs_save = termios.tcgetattr(fd)
    # make raw - the way to do this comes from the termios(3) man page.
    attrs = list(attrs_save)  # copy the stored version to update
    # iflag
    attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK |
                  termios.ISTRIP | termios.INLCR | termios.IGNCR |
                  termios.ICRNL | termios.IXON)
    # oflag
    attrs[1] &= ~termios.OPOST
    # cflag
    attrs[2] &= ~(termios.CSIZE | termios. PARENB)
    attrs[2] |= termios.CS8
    # lflag
    attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON |
                  termios.ISIG | termios.IEXTEN)
    termios.tcsetattr(fd, termios.TCSANOW, attrs)
    # turn off non-blocking
    fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
    # read a single keystroke
    try:
        ret = sys.stdin.read(1)  # returns a single character
    except KeyboardInterrupt:
        ret = 0
    finally:
        # restore old state
        termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save)
        fcntl.fcntl(fd, fcntl.F_SETFL, flags_save)
    return ret 
开发者ID:seperman,项目名称:fast-autocomplete,代码行数:48,代码来源:misc.py


注:本文中的termios.ISIG属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。