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


Python GLib.IO_IN属性代码示例

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


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

示例1: copy_files

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def copy_files(self, file_name, action):

        if action == 'make_backup':
            command = ['cp', '-R', self.winetricks_cache + '/' + file_name, self.winetricks_cache_backup]
        elif action == 'restore_backup':
            command = ['cp', '-R', self.winetricks_cache_backup + '/' + file_name, self.winetricks_cache]

        self.pid, stdin, stdout, stderr = GLib.spawn_async(command,
                                    flags=GLib.SpawnFlags.SEARCH_PATH|GLib.SpawnFlags.DO_NOT_REAP_CHILD,
                                    standard_output=True,
                                    standard_error=True)

        io = GLib.IOChannel(stdout)

        self.source_id_out = io.add_watch(GLib.IO_IN|GLib.IO_HUP,
                             self.watch_process,
                             'copy_files',
                             priority=GLib.PRIORITY_HIGH) 
开发者ID:yancharkin,项目名称:games_nebula,代码行数:20,代码来源:winetricks_cache_backup.py

示例2: test_handle_connection

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_handle_connection(self):
        self.mock.accept_connection.return_value = (
            sentinel.sock,
            sentinel.addr,
        )
        self.mock.maximum_connections_exceeded.return_value = False

        assert network.Server.handle_connection(
            self.mock, sentinel.fileno, GLib.IO_IN
        )
        self.mock.accept_connection.assert_called_once_with()
        self.mock.maximum_connections_exceeded.assert_called_once_with()
        self.mock.init_connection.assert_called_once_with(
            sentinel.sock, sentinel.addr
        )
        assert 0 == self.mock.reject_connection.call_count 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:18,代码来源:test_server.py

示例3: test_handle_connection_exceeded_connections

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_handle_connection_exceeded_connections(self):
        self.mock.accept_connection.return_value = (
            sentinel.sock,
            sentinel.addr,
        )
        self.mock.maximum_connections_exceeded.return_value = True

        assert network.Server.handle_connection(
            self.mock, sentinel.fileno, GLib.IO_IN
        )
        self.mock.accept_connection.assert_called_once_with()
        self.mock.maximum_connections_exceeded.assert_called_once_with()
        self.mock.reject_connection.assert_called_once_with(
            sentinel.sock, sentinel.addr
        )
        assert 0 == self.mock.init_connection.call_count 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:18,代码来源:test_server.py

示例4: sock_accept

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def sock_accept(self, sock):
        channel = self._channel_from_socket(sock)
        source = GLib.io_create_watch(channel, GLib.IO_IN)

        def sock_connection_received(sock):
            return (True, sock.accept())

        @asyncio.coroutine
        def accept_coro(future, conn):
            # Coroutine closing the accept socket if the future is cancelled
            try:
                return (yield from future)
            except futures.CancelledError:
                sock.close()
                raise

        future = self._delayed(source, sock_connection_received, sock)
        return self.create_task(accept_coro(future, sock)) 
开发者ID:pychess,项目名称:pychess,代码行数:20,代码来源:glib_events.py

示例5: register_server_socket

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def register_server_socket(self, fileno):
        return GLib.io_add_watch(fileno, GLib.IO_IN, self.handle_connection) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:4,代码来源:network.py

示例6: enable_recv

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def enable_recv(self):
        if self.recv_id is not None:
            return

        try:
            self.recv_id = GLib.io_add_watch(
                self._sock.fileno(),
                GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP,
                self.recv_callback,
            )
        except OSError as exc:
            self.stop(f"Problem with connection: {exc}") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:14,代码来源:network.py

示例7: test_register_server_socket_sets_up_io_watch

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_register_server_socket_sets_up_io_watch(self):
        network.Server.register_server_socket(self.mock, sentinel.fileno)
        GLib.io_add_watch.assert_called_once_with(
            sentinel.fileno, GLib.IO_IN, self.mock.handle_connection
        ) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:7,代码来源:test_server.py

示例8: test_recv_callback_respects_io_err

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_respects_io_err(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock.actor_ref = Mock()

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, (GLib.IO_IN | GLib.IO_ERR)
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:10,代码来源:test_connection.py

示例9: test_recv_callback_respects_io_hup

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_respects_io_hup(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock.actor_ref = Mock()

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, (GLib.IO_IN | GLib.IO_HUP)
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:10,代码来源:test_connection.py

示例10: test_recv_callback_respects_io_hup_and_io_err

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_respects_io_hup_and_io_err(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock.actor_ref = Mock()

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, ((GLib.IO_IN | GLib.IO_HUP) | GLib.IO_ERR)
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:10,代码来源:test_connection.py

示例11: test_recv_callback_sends_data_to_actor

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_sends_data_to_actor(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock._sock.recv.return_value = b"data"
        self.mock.actor_ref = Mock()

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, GLib.IO_IN
        )
        self.mock.actor_ref.tell.assert_called_once_with({"received": b"data"}) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:11,代码来源:test_connection.py

示例12: test_recv_callback_handles_dead_actors

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_handles_dead_actors(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock._sock.recv.return_value = b"data"
        self.mock.actor_ref = Mock()
        self.mock.actor_ref.tell.side_effect = pykka.ActorDeadError()

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, GLib.IO_IN
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:12,代码来源:test_connection.py

示例13: test_recv_callback_recoverable_error

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_recoverable_error(self):
        self.mock._sock = Mock(spec=socket.SocketType)

        for error in (errno.EWOULDBLOCK, errno.EINTR):
            self.mock._sock.recv.side_effect = socket.error(error, "")
            assert network.Connection.recv_callback(
                self.mock, sentinel.fd, GLib.IO_IN
            )
            assert 0 == self.mock.stop.call_count 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:11,代码来源:test_connection.py

示例14: test_recv_callback_unrecoverable_error

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_recv_callback_unrecoverable_error(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock._sock.recv.side_effect = socket.error

        assert network.Connection.recv_callback(
            self.mock, sentinel.fd, GLib.IO_IN
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:10,代码来源:test_connection.py

示例15: test_send_callback_respects_io_err

# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import IO_IN [as 别名]
def test_send_callback_respects_io_err(self):
        self.mock._sock = Mock(spec=socket.SocketType)
        self.mock._sock.send.return_value = 1
        self.mock.send_lock = Mock()
        self.mock.actor_ref = Mock()
        self.mock.send_buffer = b""

        assert network.Connection.send_callback(
            self.mock, sentinel.fd, (GLib.IO_IN | GLib.IO_ERR)
        )
        self.mock.stop.assert_called_once_with(any_unicode) 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:13,代码来源:test_connection.py


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