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