def unsubscribe(self, receiver): """Stop notifying a receiver about any criteria.""" for signal in self._criteria_signals.itervalues(): try: louie.disconnect(receiver, signal) except louie.error.DispatcherKeyError: pass
def _on_active_world_change(self, active_world): """Refresh a tree view with the new root element.""" if active_world!=self._active_world: self._active_world = active_world model = self.model() # disconnect for previous world selection events if model is not None and model.metaworld_tree is not None: old_world = model.metaworld_tree.world louie.disconnect( self._on_selection_change, metaworldui.WorldSelectionChanged, old_world ) # connect to new world selection events & refresh tree view if model is None or active_world is None: model.set_metaworld_tree( None ) #self.clear() else: model_tree = active_world.find_tree( model.meta_tree ) if model_tree is not None: louie.connect( self._on_selection_change, metaworldui.WorldSelectionChanged, active_world ) model.set_metaworld_tree( model_tree ) self._expand_roots() self.resizeColumnToContents(0) self.show() else: # the new world has no tree of the type of the view self.hide()
def set_metaworld_tree( self, tree ): #assert tree is not None #assert tree.meta == self._meta_tree, (tree.meta, self._meta_tree) # setup event listener for the tree # Notes: somehow the tree remain empty if we do not allow setting twice. To investigate... # if tree == self._metaworld_tree: # return if self._metaworld_tree is not None: self._metaworld_tree.disconnect_from_element_events( self._onElementAdded, self._onElementUpdated, self._onElementAboutToBeRemoved ) louie.disconnect( self._on_element_issues_updated, metaworldui.ElementIssuesUpdated, self._metaworld_tree.world ) self._metaworld_tree = tree self._issue_tracker = tree is not None and tree.world or None if tree is not None: self._metaworld_tree.connect_to_element_events( self._onElementAdded, self._onElementUpdated, self._onElementAboutToBeRemoved ) louie.connect( self._on_element_issues_updated, metaworldui.ElementIssuesUpdated, self._metaworld_tree.world ) self._refreshTreeRoot() else: self.clear()
def cmd_search_delete(self, idOfFilter): for sf in self.searchFilters: if id(sf) == idOfFilter: louie.disconnect(self.onSearchResult, 'search:result', sf) sf.cancel() self.searchFilters.remove(sf) break
def deactivate(self, shell): self.info("Coherence UPnP plugin deactivated") if self.coherence is None: return self.coherence.shutdown() try: louie.disconnect(self.detected_media_server, 'Coherence.UPnP.ControlPoint.MediaServer.detected', louie.Any) except louie.error.DispatcherKeyError: pass try: louie.disconnect(self.removed_media_server, 'Coherence.UPnP.ControlPoint.MediaServer.removed', louie.Any) except louie.error.DispatcherKeyError: pass del self.shell del self.coherence for usn, source in self.sources.iteritems(): source.delete_thyself() del self.sources
def test_Exact(self): a = Dummy() signal = 'this' louie.connect(x, signal, a) expected = [(x, a)] result = louie.send('this', a, a=a) assert result == expected, ( "Send didn't return expected result:\n\texpected:{0}\n\tgot:{1}" .format(expected, result)) louie.disconnect(x, signal, a) assert len(list(louie.get_all_receivers(a, signal))) == 0 self._isclean()
def test_AnonymousSend(self): a = Dummy() signal = 'this' louie.connect(x, signal) expected = [(x, a)] result = louie.send(signal, None, a=a) assert result == expected, ( "Send didn't return expected result:\n\texpected:%s\n\tgot:%s" % (expected, result)) louie.disconnect(x, signal) assert len(list(louie.get_all_receivers(None, signal))) == 0 self._isclean()
def test_AllRegistration(self): a = Dummy() signal = 'this' louie.connect(x, louie.All, a) expected = [(x, a)] result = louie.send('this', a, a=a) assert result == expected, ( "Send didn't return expected result:\n\texpected:%s\n\tgot:%s" % (expected, result)) louie.disconnect(x, louie.All, a) assert len(list(louie.get_all_receivers(a, louie.All))) == 0 self._isclean()
def _resetPropertyListModel( self, element = None ): """Change the element displayed in the property list. Subscribe to update event for the element and unsubscribe from the old one. """ self.clear() self.setHorizontalHeaderLabels( [self.tr('Name'), self.tr('Value')] ) if self._element_tree is not None: louie.disconnect( self.__on_element_updated, metaworld.AttributeUpdated, self._element_tree ) self._element_tree = None self._element = element if element is not None: self._element_tree = element.tree louie.connect( self.__on_element_updated, metaworld.AttributeUpdated, self._element_tree )
def test_AnyRegistration(self): a = Dummy() signal = 'this' louie.connect(x, signal, louie.Any) expected = [(x, a)] result = louie.send('this', object(), a=a) assert result == expected, ( "Send didn't return expected result:\n\texpected:%s\n\tgot:%s" % (expected, result)) louie.disconnect(x, signal, louie.Any) expected = [] result = louie.send('this', object(), a=a) assert result == expected, ( "Send didn't return expected result:\n\texpected:%s\n\tgot:%s" % (expected, result)) assert len(list(louie.get_all_receivers(louie.Any, signal))) == 0 self._isclean()
def test_AnyRegistration(self): a = Dummy() signal = "this" louie.connect(x, signal, louie.Any) expected = [(x, a)] result = louie.send(signal, object(), a=a) assert ( result == expected ), f"Send didn't return expected result:\n\texpected:{expected}\n\tgot:{result}" louie.disconnect(x, signal, louie.Any) expected = [] result = louie.send(signal, object(), a=a) assert ( result == expected ), f"Send didn't return expected result:\n\texpected:{expected}\n\tgot:{result}" assert len(list(louie.get_all_receivers(louie.Any, signal))) == 0 self._isclean()
def _on_active_world_change(self, active_world): if self._active_world!=active_world: if self._active_world is not None: louie.disconnect( self._on_selection_change, metaworldui.WorldSelectionChanged, self._active_world ) louie.disconnect( self._on_element_issues_updated, metaworldui.ElementIssuesUpdated, self._active_world ) self._active_world = active_world if active_world is not None: louie.connect( self._on_selection_change, metaworldui.WorldSelectionChanged, active_world ) louie.connect( self._on_element_issues_updated, metaworldui.ElementIssuesUpdated, self._active_world ) louie.send( metaworldui.WorldSelectionChanged, active_world, active_world.selected_elements, active_world.selected_elements, None ) else: self.clear()
def receiver1(): if disconnect_receiver1: louie.disconnect(receiver1, signal) return 1
def connectionLost(self, reason): #FIXME: There's got to be a better way than this louie.disconnect(self.translator, 'hub:status') louie.disconnect(self.translator, 'hub:name') louie.disconnect(self.translator, 'hub:global_to') louie.disconnect(self.translator, 'hub:to') louie.disconnect(self.translator, 'hub:chat_room') louie.disconnect(self.translator, 'hub:sent_to') louie.disconnect(self.translator, 'hub:user:new') louie.disconnect(self.translator, 'hub:user:update') louie.disconnect(self.translator, 'hub:user:quit') louie.disconnect(self.translator, 'peer:new') louie.disconnect(self.translator, 'peer:quit') louie.disconnect(self.translator, 'peer:upload:start') louie.disconnect(self.translator, 'peer:upload:progress') louie.disconnect(self.translator, 'peer:upload:end') louie.disconnect(self.translator, 'peer:download:start') louie.disconnect(self.translator, 'peer:download:progress') louie.disconnect(self.translator, 'peer:download:end') louie.disconnect(self.translator, 'share_store:walking') louie.disconnect(self.translator, 'share_store:walking:done') louie.disconnect(self.translator, 'share_store:hashing') louie.disconnect(self.translator, 'share_store:hashed') louie.disconnect(self.translator, 'share_store:size') louie.disconnect(self.translator, 'share_store:indexer:finished')
def _cleanUp(self): louie.disconnect(self.onPeerTransferStart, 'peer:download:start') louie.disconnect(self.onPeerTransferStart, 'peer:upload:start') louie.disconnect(self.onPeerTransferEnd, 'peer:download:end') louie.disconnect(self.onPeerTransferEnd, 'peer:upload:end')
def disconnect(self, signal, receiver): """Reverse of ``connect``.""" louie.disconnect(receiver, signal, self) self.__receivers.remove((receiver, signal))
def stopService(self): service.Service.stopService(self) louie.disconnect(self.onHubUserNew, 'hub:user:new') louie.disconnect(self.onDownloadQueued, 'download:queued') louie.disconnect(self.onDownloaderFinished, 'downloader:finished') louie.disconnect(self.onDownloaderStatus, 'downloader:status') louie.disconnect(self.onPeerIdle, 'peer:idle') louie.disconnect(self.onHubConnected, 'hub:connected') louie.disconnect(self.onHubQuit, 'hub:quit') self.log('stopping addMoreDownloaderCall') for dl in self.downloaders.values(): try: dl.cancel() except Exception, ee: log.err(ee)
def stopService(self): louie.disconnect(self.onDownloadFinished, 'download:finished') if self.updateSizeDelayedCall and self.updateSizeDelayedCall.active(): self.updateSizeDelayedCall.cancel() self.updateSizeDelayedCall = None yield service.Service.stopService(self)
def stopService(self): service.Service.stopService(self) louie.disconnect(self.onPeerNew, 'peer:new') louie.disconnect(self.onPeerQuit, 'peer:quit') louie.disconnect(self.onHubUserUpdate, 'hub:user:update') louie.disconnect(self.onHubUserQuit, 'hub:user:quit') louie.disconnect(self.onSearchResultRaw, 'search:result:raw') louie.disconnect(self.onPeerTimeout, 'peer:timeout') louie.disconnect(self.onPeerMaxedOut, 'peer:maxed_out') for peer, waiting in self._waitingForConnection.items(): waiting['connectedTimeoutDelayCall'].cancel() for delayedCall in self._waitingToConnect.values(): if delayedCall.active(): delayedCall.cancel() for connection in self.connections: connection.transport.loseConnection()
def killBeforeAfter(self): #{{{ louie.disconnect(base_before, 'before_after', base_signal) louie.disconnect(base_signal, 'before_after', base_signal) louie.disconnect(base_after, 'before_after', base_signal)
def _(peer, sent_at, msg): louie.disconnect(_, "hub:to") self.assertEqual(message, msg)
def cancel(self, deferred=None): log.msg('CANCELING %r' % (self,)) louie.disconnect(self.filter, 'search:result:raw') for dd in self.deferreds: dd.cancel()
def remove(self, item): if item in self.items: self.items.remove(item) disconnect(self.markdirty, item.changed) disconnect(item.mouseclick, self.mouseclick) self.needs_update = True