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


Python termios.FIONREAD属性代码示例

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


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

示例1: read_events

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def read_events(self):
        """
        Read events from device, build _RawEvents, and enqueue them.
        """
        buf_ = array.array('i', [0])
        # get event queue size
        if fcntl.ioctl(self._fd, termios.FIONREAD, buf_, 1) == -1:
            return
        queue_size = buf_[0]
        if queue_size < self._threshold:
            log.debug('(fd: %d) %d bytes available to read but threshold is '
                      'fixed to %d bytes', self._fd, queue_size,
                      self._threshold)
            return

        try:
            # Read content from file
            r = os.read(self._fd, queue_size)
        except Exception, msg:
            raise NotifierError(msg) 
开发者ID:restran,项目名称:hacker-scripts,代码行数:22,代码来源:pyinotify.py

示例2: _is_closed_select

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def _is_closed_select(f):
    rlist, wlist, _ = select.select([f], [f], [], 0.0)
    if not rlist and not wlist:
        return False
    buf = array.array('i', [0])
    fcntl.ioctl(f.fileno(), termios.FIONREAD, buf)
    return buf[0] == 0 
开发者ID:getsentry,项目名称:rb,代码行数:9,代码来源:poll.py

示例3: in_waiting

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def in_waiting(self):
        """Return the number of bytes currently in the input buffer."""
        #~ s = fcntl.ioctl(self.fd, termios.FIONREAD, TIOCM_zero_str)
        s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
        return struct.unpack('I', s)[0]

    # select based implementation, proved to work on many systems 
开发者ID:cedricp,项目名称:ddt4all,代码行数:9,代码来源:serialposix.py

示例4: out_waiting

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def out_waiting(self):
        """Return the number of bytes currently in the output buffer."""
        #~ s = fcntl.ioctl(self.fd, termios.FIONREAD, TIOCM_zero_str)
        s = fcntl.ioctl(self.fd, TIOCOUTQ, TIOCM_zero_str)
        return struct.unpack('I', s)[0] 
开发者ID:cedricp,项目名称:ddt4all,代码行数:7,代码来源:serialposix.py

示例5: _running_jobs

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def _running_jobs(cls):

        try:
            buf = array.array('i', [0])
            if fcntl.ioctl(cls._job_pipe[0], FIONREAD, buf) == 0:
                return cls._max_jobs - buf[0]
        except (NotImplementedError, OSError):
            pass

        return cls._max_jobs 
开发者ID:catkin,项目名称:catkin_tools,代码行数:12,代码来源:job_server.py

示例6: read_events

# 需要导入模块: import termios [as 别名]
# 或者: from termios import FIONREAD [as 别名]
def read_events(self):
        """
        Read events from device, build _RawEvents, and enqueue them.
        """
        buf_ = array.array('i', [0])
        # get event queue size
        if fcntl.ioctl(self._fd, termios.FIONREAD, buf_, 1) == -1:
            return
        queue_size = buf_[0]
        if queue_size < self._threshold:
            log.debug('(fd: %d) %d bytes available to read but threshold is '
                      'fixed to %d bytes', self._fd, queue_size,
                      self._threshold)
            return

        try:
            # Read content from file
            r = os.read(self._fd, queue_size)
        except Exception as msg:
            raise NotifierError(msg)
        log.debug('Event queue size: %d', queue_size)
        rsum = 0  # counter
        while rsum < queue_size:
            s_size = 16
            # Retrieve wd, mask, cookie and fname_len
            wd, mask, cookie, fname_len = struct.unpack('iIII',
                                                        r[rsum:rsum+s_size])
            # Retrieve name
            bname, = struct.unpack('%ds' % fname_len,
                                   r[rsum + s_size:rsum + s_size + fname_len])
            # FIXME: should we explictly call sys.getdefaultencoding() here ??
            uname = bname.decode()
            rawevent = _RawEvent(wd, mask, cookie, uname)
            if self._coalesce:
                # Only enqueue new (unique) events.
                raweventstr = str(rawevent)
                if raweventstr not in self._eventset:
                    self._eventset.add(raweventstr)
                    self._eventq.append(rawevent)
            else:
                self._eventq.append(rawevent)
            rsum += s_size + fname_len 
开发者ID:epi052,项目名称:recursive-gobuster,代码行数:44,代码来源:pyinotify.py


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