Python fcntl.F_GETFL属性代码示例

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

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

示例1: read_char_no_blocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def read_char_no_blocking():
    ''' Read a character in nonblocking mode, if no characters are present in the buffer, return an empty string '''
    fd = sys.stdin.fileno()
    old_settings = termios.tcgetattr(fd)
    old_flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    try:
        tty.setraw(fd, termios.TCSADRAIN)
        fcntl.fcntl(fd, fcntl.F_SETFL, old_flags | os.O_NONBLOCK)
        return sys.stdin.read(1)
    except IOError as e:
        ErrorNumber = e[0]
        # IOError with ErrorNumber 11(35 in Mac)  is thrown when there is nothing to read(Resource temporarily unavailable)
        if (sys.platform.startswith("linux") and ErrorNumber != 11) or (sys.platform == "darwin" and ErrorNumber != 35):
            raise
        return ""
    finally:
        fcntl.fcntl(fd, fcntl.F_SETFL, old_flags)
        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) 
开发者ID:pindexis,项目名称:marker,代码行数:20,代码来源:readchar.py


示例2: train

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def train(self):
        i=0
        if(self.args.ipython):
            import fcntl
            fd = sys.stdin.fileno()
            fl = fcntl.fcntl(fd, fcntl.F_GETFL)
            fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
        while((i < self.total_steps or self.total_steps == -1) and not self.gan.destroy):
            i+=1
            start_time = time.time()
            self.step()
            GlobalViewer.tick()
            if (self.args.save_every != None and
                self.args.save_every != -1 and
                self.args.save_every > 0 and
                i % self.args.save_every == 0):
                print(" |= Saving network")
                self.gan.save(self.save_file)
            if self.args.ipython:
                self.check_stdin()
            end_time = time.time() 
开发者ID:HyperGAN,项目名称:HyperGAN,代码行数:25,代码来源:cli.py


示例3: blocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def blocking(self, port, mode=False):
        """
        Set port function mode blocking/nonblocking
        :param port: port to set mode
        :param mode: False to set nonblock mode, True for block mode
        """
        fd = self._open([port])[0]
        try:
            fl = fcntl.fcntl(fd, fcntl.F_GETFL)
            if not mode:
                fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
            else:
                fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_NONBLOCK)
        except Exception as inst:
            print("FAIL: Setting (non)blocking mode: " + str(inst))
            return
        if mode:
            print("PASS: set to blocking mode")
        else:
            print("PASS: set to nonblocking mode") 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:26,代码来源:virtio_console_guest.py


示例4: set_blocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def set_blocking(fd, blocking=True):
    """
    Set the given file-descriptor blocking or non-blocking.
    Returns the original blocking status.
    """
    old_flag = fcntl.fcntl(fd, fcntl.F_GETFL)
    if blocking:
        new_flag = old_flag & ~ os.O_NONBLOCK
    else:
        new_flag = old_flag | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, new_flag)
    return not bool(old_flag & os.O_NONBLOCK) 
开发者ID:QData,项目名称:deepWordBug,代码行数:19,代码来源:io.py


示例5: __init__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def __init__(self, pScene):
        self.pScene = pScene
        #self.infile_path = "/dev/input/event" + (sys.argv[1] if len(sys.argv) > 1 else "0")
        self.infile_path = "/dev/input/event0"
        self.FORMAT = 'llHHI'
        self.EVENT_SIZE = struct.calcsize(self.FORMAT)
        self.lastPtX = 0
        self.lastPtY = 0
        self.rateX = float(480) / 3900
        self.rateY = float(320) / 3900
        self.sep = 0
        #print str(rateX)
        #print str(rateY)
        self.in_file = open(self.infile_path, "rb")
        flag = fcntl.fcntl(self.in_file, fcntl.F_GETFL)
        fcntl.fcntl(self.in_file, fcntl.F_SETFL, os.O_NONBLOCK) 
开发者ID:KONAMI,项目名称:EM-uNetPi,代码行数:18,代码来源:TouchManager.py


示例6: set_nonblock

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def set_nonblock(self, set_flag=True):
        """Set the non blocking flag on the socket"""
        # Get the current flags
        if self.fd_flags is None:
            try:
                self.fd_flags = fcntl.fcntl(self.ins, fcntl.F_GETFL)
            except IOError:
                warning("Cannot get flags on this file descriptor !")
                return
        # Set the non blocking flag
        if set_flag:
            new_fd_flags = self.fd_flags | os.O_NONBLOCK
        else:
            new_fd_flags = self.fd_flags & ~os.O_NONBLOCK
        try:
            fcntl.fcntl(self.ins, fcntl.F_SETFL, new_fd_flags)
            self.fd_flags = new_fd_flags
        except Exception:
            warning("Can't set flags on this file descriptor !") 
开发者ID:secdev,项目名称:scapy,代码行数:24,代码来源:supersocket.py


示例7: __init__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def __init__(self, command):
        """
        Creates an interactive process to interact with out of a command
        :param str command: the command to be executed
        """
        from fcntl import fcntl, F_GETFL, F_SETFL
        from subprocess import Popen, PIPE
        import os
        self._command = command
        self._executable = command.split(" ", 1)[0]
        _Log.debug("Starting the interactive process: {}".format(command))
        self._process = Popen(command, shell=True, stdout=PIPE, stdin=PIPE,
            stderr=PIPE)
        fcntl(self._process.stdin, F_SETFL,
            fcntl(self._process.stdin, F_GETFL) | os.O_NONBLOCK)
        fcntl(self._process.stdout, F_SETFL,
            fcntl(self._process.stdout, F_GETFL) | os.O_NONBLOCK)
        fcntl(self._process.stderr, F_SETFL,
            fcntl(self._process.stderr, F_GETFL) | os.O_NONBLOCK) 
开发者ID:nettitude,项目名称:scrounger,代码行数:26,代码来源:general.py


示例8: set_fd_status_flag

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def set_fd_status_flag(fd, flag):
    """Set a status flag on a file descriptor.
    ``fd`` is the file descriptor or file object, ``flag`` the flag as integer.
    """
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    fcntl.fcntl(fd, fcntl.F_SETFL, flags | flag) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:10,代码来源:pipe.py


示例9: SetFileNonBlocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def SetFileNonBlocking(f, non_blocking=True):
  """Set non-blocking flag on a file object.
  Args:
    f: file
    non_blocking: bool, default True, non-blocking mode or not
  """
  flags = fcntl.fcntl(f.fileno(), fcntl.F_GETFL)
  if bool(flags & os.O_NONBLOCK) != non_blocking:
    flags ^= os.O_NONBLOCK
  fcntl.fcntl(f.fileno(), fcntl.F_SETFL, flags) 
开发者ID:google,项目名称:macops,代码行数:13,代码来源:gmacpyutil.py


示例10: _set_nonblocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def _set_nonblocking(fd):
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:5,代码来源:posix.py


示例11: _set_nonblocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def _set_nonblocking(self, fd):
        flags = fcntl.fcntl(fd, fcntl.F_GETFL)
        fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:5,代码来源:twisted_test.py


示例12: activate

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def activate(self):
        """Set up signal handlers.
        On Windows this uses a QTimer to periodically hand control over to
        Python so it can handle signals.
        On Unix, it uses a QSocketNotifier with os.set_wakeup_fd to get
        notified.
        """
        self._orig_handlers[signal.SIGINT] = signal.signal(
            signal.SIGINT, self.interrupt)
        self._orig_handlers[signal.SIGTERM] = signal.signal(
            signal.SIGTERM, self.interrupt)
        if utils.is_posix and hasattr(signal, 'set_wakeup_fd'):
            # pylint: disable=import-error,no-member,useless-suppression
            import fcntl
            read_fd, write_fd = os.pipe()
            for fd in [read_fd, write_fd]:
                flags = fcntl.fcntl(fd, fcntl.F_GETFL)
                fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
            self._notifier = QSocketNotifier(typing.cast(sip.voidptr, read_fd),
                                             QSocketNotifier.Read,
                                             self)
            self._notifier.activated.connect(  # type: ignore[attr-defined]
                self.handle_signal_wakeup)
            self._orig_wakeup_fd = signal.set_wakeup_fd(write_fd)
            # pylint: enable=import-error,no-member,useless-suppression
        else:
            self._timer.start(1000)
            self._timer.timeout.connect(lambda: None)
        self._activated = True 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:34,代码来源:crashsignal.py


示例13: set_binary_mode

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def set_binary_mode(f):
            try:
                fileno = f.fileno()
            except Exception:
                pass
            else:
                flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
                fcntl.fcntl(fileno, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
            return f 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:_compat.py


示例14: set_non_blocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def set_non_blocking(fd):
    flags = fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:util.py


示例15: __init__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def __init__(self, height):
        super(Terminal, self).__init__(height, line_wrap=True, parser=AnsiTerminalParser())
        #Key definitions
        self._map = {}
        for k, v in [
            (Screen.KEY_LEFT, "kcub1"),
            (Screen.KEY_RIGHT, "kcuf1"),
            (Screen.KEY_UP, "kcuu1"),
            (Screen.KEY_DOWN, "kcud1"),
            (Screen.KEY_HOME, "khome"),
            (Screen.KEY_END, "kend"),
            (Screen.KEY_BACK, "kbs"),
        ]:
            self._map[k] = curses.tigetstr(v)
        self._map[Screen.KEY_TAB] = "\t".encode()
        # Open a pseudo TTY to control the interactive session.  Make it non-blocking.
        self._master, slave = pty.openpty()
        fl = fcntl.fcntl(self._master, fcntl.F_GETFL)
        fcntl.fcntl(self._master, fcntl.F_SETFL, fl | os.O_NONBLOCK)
        # Start the shell and thread to pull data from it.
        self._shell = subprocess.Popen(["bash", "-i"], preexec_fn=os.setsid, stdin=slave, stdout=slave, stderr=slave)
        self._lock = threading.Lock()
        self._thread = threading.Thread(target=self._background)
        self._thread.daemon = True
        self._thread.start() 
开发者ID:peterbrittain,项目名称:asciimatics,代码行数:30,代码来源:terminal.py


示例16: __init__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def __init__(self, fd, map=None):
            dispatcher.__init__(self, None, map)
            self.connected = True
            try:
                fd = fd.fileno()
            except AttributeError:
                pass
            self.set_file(fd)
            # set it to non-blocking mode
            flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
            flags = flags | os.O_NONBLOCK
            fcntl.fcntl(fd, fcntl.F_SETFL, flags) 
开发者ID:glmcdona,项目名称:meddle,代码行数:14,代码来源:asyncore.py


示例17: flags

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def flags(self, *which):
        import fcntl, os
        if which:
            if len(which) > 1:
                raise TypeError, 'Too many arguments'
            which = which[0]
        else: which = '?'
        l_flags = 0
        if 'n' in which: l_flags = l_flags | os.O_NDELAY
        if 'a' in which: l_flags = l_flags | os.O_APPEND
        if 's' in which: l_flags = l_flags | os.O_SYNC
        file = self._file_
        if '=' not in which:
            cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
            if '!' in which: l_flags = cur_fl & ~ l_flags
            else: l_flags = cur_fl | l_flags
        l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
        if 'c' in which:
            arg = ('!' not in which)    # 0 is don't, 1 is do close on exec
            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
        if '?' in which:
            which = ''                  # Return current flags
            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
            if os.O_APPEND & l_flags: which = which + 'a'
            if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
                which = which + 'c'
            if os.O_NDELAY & l_flags: which = which + 'n'
            if os.O_SYNC & l_flags: which = which + 's'
            return which 
开发者ID:glmcdona,项目名称:meddle,代码行数:38,代码来源:posixfile.py


示例18: setUp

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def setUp(self):
        import fcntl
        self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None)
        self.read, self.write = os.pipe()
        flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0)
        flags = flags | os.O_NONBLOCK
        fcntl.fcntl(self.write, fcntl.F_SETFL, flags)
        self.old_wakeup = signal.set_wakeup_fd(self.write) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_signal.py


示例19: _set_non_blocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def _set_non_blocking(self, fd):
        flags = fcntl.fcntl(fd, fcntl.F_GETFL)
        self.assertNotEqual(flags, -1)
        res = fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
        self.assertEqual(res, 0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_io.py


示例20: _set_nonblocking

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def _set_nonblocking(fd: int) -> None:
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:5,代码来源:posix.py


示例21: nonBlockClear

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import F_GETFL [as 别名]
def nonBlockClear(fd):
    "clear the non-blocking flag on a fd"
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, flags&~os.O_NONBLOCK) 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:6,代码来源:pipeline.py



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