def register_socket(self, socket): if socket not in self.sockets: self.sockets.append(socket) socket.read_notifier = QSocketNotifier(socket.fileno(), QSocketNotifier.Read) self.connect(socket.read_notifier, SIGNAL("activated(int)"), self.read_socket) socket.read_notifier.setEnabled(socket.readable()) socket.write_notifier = QSocketNotifier(socket.fileno(), QSocketNotifier.Write) self.connect(socket.write_notifier, SIGNAL("activated(int)"), self.write_socket) socket.write_notifier.setEnabled(socket.writable())
def hook_fd(fd, obj): handler_table = [ (QSocketNotifier.Read, make_handler(select.POLLIN)), #POLLIN (QSocketNotifier.Write, make_handler(select.POLLOUT)), #POLLOUT (QSocketNotifier.Exception, make_handler(select.POLLERR))] #POLLERR for evtype, handler in handler_table: n = QSocketNotifier(fd, evtype) n.activated.connect(handler) notifiers[fd].append(n)
def _addNotifier(self, descriptor, descmap, type): if descriptor not in descmap: fd = descriptor.fileno() if fd == -1: raise RuntimeError("Invalid file descriptor") notifier = QSocketNotifier(fd, type) descmap[descriptor] = notifier notifier._descriptor = descriptor self.connect(notifier, SIGNAL("activated(int)"), self._notifierSlot) notifier.setEnabled(True)
def __init__(self, parent, reactor, watcher, socketType): QObject.__init__(self, parent) self.reactor = reactor self.watcher = watcher fd = watcher.fileno() self.notifier = QSocketNotifier(fd, socketType, parent) self.notifier.setEnabled(True) if socketType == QSocketNotifier.Read: self.fn = self.read else: self.fn = self.write QObject.connect(self.notifier, SIGNAL("activated(int)"), self.fn)
def _SH_ThreadStarted(self): self.started.emit() notification_center = NotificationCenter() notification_center.post_notification('VNCClientWillStart', sender=self) self.rfb_client = RFBClient(parent=self) try: self.rfb_client.connect() except RFBClientError: self.thread.quit() else: self.socket_notifier = QSocketNotifier(self.rfb_client.socket, QSocketNotifier.Read, self) self.socket_notifier.activated.connect(self._SH_SocketNotifierActivated) notification_center.post_notification('VNCClientDidStart', sender=self)
def __init__(self, rndfFname, skelFname, modelFname): QMainWindow.__init__(self) self.setupUi(self) self.skelFname = skelFname self.rndfFname = rndfFname self.rndf = rndf(self.rndfFname) assert rndf != None self.taskPlanner = BeamSearch(CostFnCrf.from_mallet(modelFname), useRrt=False) self.stateApp = state_extractor.App(self.rndfFname) self.actionApp = action_executor.App(rndf_file=self.rndfFname) self.agileRun = agile_videos.AgileRun(self.stateApp.lc, startSheriff=False) self.socket = QSocketNotifier(self.stateApp.lc.fileno(), QSocketNotifier.Read) self.stateApp.lc.subscribe("SPEECH", self.onSpeech) self.connect(self.socket, SIGNAL("activated(int)"), self.socketActivated) self.cfBrowser = costFunctionBrowser.MainWindow(ForkliftBrowserTools(), self.taskPlanner, initialState=False) self.cfBrowser.show() self.connect(self.submitButton, SIGNAL("clicked()"), self.followCommand) self.connect(self.sendActionButton, SIGNAL("clicked()"), self.sendAction) self.connect(self.viewStateButton, SIGNAL("clicked()"), self.updateState) signal.signal (signal.SIGINT, lambda *s: self.cleanup()) load_maps()
def register_io(self, fd, callback, mode, *args, **kwargs): handler = six.next(self._handlers) notifier = QSocketNotifier(self.fd_number(fd), self.constants[mode]) with self._mutex: self._io_handlers[handler] = notifier def _io_cb(*_): if not self._safe_callback(callback, fd, *args, **kwargs): self.unregister_io(handler) with self._mutex: # we need to store the closure callback to avoid the garbage collector # from collecting the closure self._io_handlers[handler] = (notifier, _io_cb) notifier.setEnabled(True) notifier.activated.connect(_io_cb)
def __init__(self, *args, **kw): self.note = QSocketNotifier(*args, **kw) self.note.setEnabled(False) Event.__init__(self, self.note.activated)
def create_watch(self, socket, type, callback): socket.setblocking(0) notifier = QSocketNotifier(socket.fileno(), type, self) notifier.activated.connect(callback) notifier.setEnabled(True) return notifier
def __init__(self, evtype, fileno, cb, tb=None, mark_as_closed=False): self.evtype, self.fileno, self.cb = evtype, fileno, cb self.tb, self.mark_as_closed = tb, mark_as_closed self.notifier = QSocketNotifier(fileno, self.eventType(evtype)) self.notifier.activated.connect(cb) self.spent = False
def run(self): self.notifier = QSocketNotifier(self.io_conn.fileno(), QSocketNotifier.Read) self.notifier.activated.connect(self.read_data) Connection.run(self)
def _addCallback(handleMap, sockfd, callback, notifyType): assert sockfd not in handleMap notifier = QSocketNotifier(sockfd, notifyType) QObject.connect(notifier, SIGNAL('activated(int)'), callback) handleMap[sockfd] = (callback, notifier)
def __init__(self, evtype, fileno, cb): self.evtype, self.fileno, self.cb = evtype, fileno, cb self.notifier = QSocketNotifier(fileno, self.eventType(evtype)) self.notifier.activated.connect(cb)