Python gobject 模块,IO_HUP 实例源码

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

项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _register_io_handlers(self):
        def handler(source, cond):
            if cond & gobject.IO_IN:
                if not self.fifo:
                    self.fifo = open(self.fifo_name, "w")

                self.fifo.write(source.recv(1024))
                return True
            else:
                self.log.debug("Error communicating with MPlayer")
                return False

        flags = gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP
        self.io_watcher_id = gobject.io_add_watch(self.data,
                                                  flags,
                                                  handler)
    # _register_io_handlers()
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def _get_mask(self, obj):
        mask = 0
        if obj.readable():
            mask |= gobject.IO_IN | gobject.IO_PRI
        if obj.writable():
            mask |= gobject.IO_OUT
        # Only watch for errors if the socket is either readable or writable
        if mask:
            mask |= gobject.IO_ERR | gobject.IO_HUP | gobject.IO_NVAL
        return mask
项目:Alexa_MMDAgent    作者:jianmliu    | 项目源码 | 文件源码
def __stdin_cb(self, fd, condition):
        if condition & gobject.IO_IN:
            line = sys.stdin.readline().decode(coding, 'ignore').rstrip('\n\r')
            if len(line) > 0:
                args = line.split('|')
                self.__service.Message(args[0], args[1:])               
        if condition & gobject.IO_HUP:
            exit()
        return True
项目:Alexa_MMDAgent    作者:jianmliu    | 项目源码 | 文件源码
def run(self):
        gobject.io_add_watch(0, gobject.IO_IN | gobject.IO_HUP, self.__stdin_cb)
        super(MainLoop, self).run()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _register_io_handlers(self):
        flags_err = gobject.IO_ERR | gobject.IO_HUP
        def handler(fd, flags):
            if flags & flags_err:
                return False
            else:
                while self.playing:
                    line = self._readline()

                    if not line:
                        return True
                    elif line[:2] == "A:" and line[-1] =="\r":
                        pieces = line.split()
                        pos = float(pieces[1])
                        self.emit("pos", pos)
                        return True
                    elif line == "Exiting... (Quit)\n":
                        self.proc.wait()
                        self.proc = None
                        self.emit("eos")
                        self.emit("state-changed", PlayerEngine.STATE_NONE)
                        return False
                    elif line == "Starting playback...\n":
                        # make buffer empty
                        while line:
                            line = self._readline(100)
                            if line and line[:2] == "A:" and line[-1] == "\r":
                                break

                        self.set_volume(self.volume)
                        self.set_mute(self.mute)
                        self.set_fullscreen(self.fullscreen)
                        self._query_media_info()
                        self._register_state_timeout()
                        self.emit("state-changed", PlayerEngine.STATE_PLAYING)
                        return True
                    else:
                        self.log.debug("Ignored MPlayer output: %r" % line)

                return True

        flags = gobject.IO_IN | gobject.IO_PRI | flags_err
        self.out_watcher = gobject.io_add_watch(self.proc.stdout,
                                                flags, handler)
    # _register_io_handlers()