本文整理汇总了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)
示例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
示例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
示例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))
示例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)
示例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}")
示例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
)
示例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)
示例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)
示例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)
示例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"})
示例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)
示例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
示例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)
示例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)