comparison src/memory/disco.py @ 2431:a9fac72825a2

memory (disco): added findServiceEntity helper method to get first service of a kind
author Goffi <goffi@goffi.org>
date Wed, 15 Nov 2017 08:54:32 +0100
parents 8b37a62336c3
children 0046283a285d
comparison
equal deleted inserted replaced
2430:3faf18111d61 2431:a9fac72825a2
228 def _infosEb(self, failure_, entity_jid): 228 def _infosEb(self, failure_, entity_jid):
229 failure_.trap(StanzaError) 229 failure_.trap(StanzaError)
230 log.warning(_(u"Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(), 230 log.warning(_(u"Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(),
231 'error': failure_.getErrorMessage()}) 231 'error': failure_.getErrorMessage()})
232 232
233 def findServiceEntity(self, client, category, type_, jid_=None):
234 """Helper method to find first available entity from findServiceEntities
235
236 args are the same as for [findServiceEntities]
237 @return (jid.JID, None): found entity
238 """
239 d = self.host.findServiceEntities(client, "pubsub", "service")
240 d.addCallback(lambda entities: entities.pop() if entities else None)
241 return d
242
233 def findServiceEntities(self, client, category, type_, jid_=None): 243 def findServiceEntities(self, client, category, type_, jid_=None):
234 """Return all available items of an entity which correspond to (category, type_) 244 """Return all available items of an entity which correspond to (category, type_)
235 245
236 @param category: identity's category 246 @param category: identity's category
237 @param type_: identitiy's type 247 @param type_: identitiy's type