當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。