本文整理匯總了Python中gobject.IO_IN屬性的典型用法代碼示例。如果您正苦於以下問題:Python gobject.IO_IN屬性的具體用法?Python gobject.IO_IN怎麽用?Python gobject.IO_IN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類gobject
的用法示例。
在下文中一共展示了gobject.IO_IN屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: inputhook
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def inputhook(context):
"""
When the eventloop of prompt-toolkit is idle, call this inputhook.
This will run the GTK main loop until the file descriptor
`context.fileno()` becomes ready.
:param context: An `InputHookContext` instance.
"""
def _main_quit(*a, **kw):
gtk.main_quit()
return False
gobject.io_add_watch(context.fileno(), gobject.IO_IN, _main_quit)
gtk.main()
示例2: inputhook_gtk
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def inputhook_gtk():
gobject.io_add_watch(sys.stdin, gobject.IO_IN, _main_quit)
gtk.main()
return 0
示例3: _install_transport_ready
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def _install_transport_ready(self):
if ('r' in self.access_type):
io_event = gobject.IO_IN
else:
io_event = gobject.IO_OUT
self.tag = gobject.io_add_watch(self.fd, io_event,
self._transport_ready_handler)
示例4: incoming_connection
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def incoming_connection(self, source, condition):
sock, info = self.server_sock.accept()
address, psm = info
self.add_text("\naccepted connection from %s" % str(address))
# add new connection to list of peers
self.peers[address] = sock
self.addresses[sock] = address
source = gobject.io_add_watch (sock, gobject.IO_IN, self.data_ready)
self.sources[address] = source
return True
示例5: start_server
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def start_server(self):
self.server_sock = bluetooth.BluetoothSocket (bluetooth.L2CAP)
self.server_sock.bind(("",0x1001))
self.server_sock.listen(1)
gobject.io_add_watch(self.server_sock,
gobject.IO_IN, self.incoming_connection)
示例6: _doReadOrWrite
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def _doReadOrWrite(self, source, condition, faildict={
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost()),
}):
why = None
inRead = False
if condition & POLL_DISCONNECTED and not (condition & gobject.IO_IN):
if source in self._reads:
why = main.CONNECTION_DONE
inRead = True
else:
why = main.CONNECTION_LOST
else:
try:
if condition & gobject.IO_IN:
why = source.doRead()
inRead = True
if not why and condition & gobject.IO_OUT:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected:
why = source.doWrite()
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, inRead)
示例7: register_intr_sock
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def register_intr_sock(self, sock):
self.sock = sock
for dev in self.devs:
gobject.io_add_watch(dev, gobject.IO_IN, self.ev_cb)
示例8: _doReadOrWrite
# 需要導入模塊: import gobject [as 別名]
# 或者: from gobject import IO_IN [as 別名]
def _doReadOrWrite(self, source, condition, faildict={
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost()),
}):
why = None
didRead = None
if condition & POLL_DISCONNECTED and \
not (condition & gobject.IO_IN):
why = main.CONNECTION_LOST
else:
try:
if condition & gobject.IO_IN:
why = source.doRead()
didRead = source.doRead
if not why and condition & gobject.IO_OUT:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected and source.doWrite != didRead:
why = source.doWrite()
didRead = source.doWrite # if failed it was in write
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, didRead == source.doRead)