Mercurial > libervia-backend
comparison src/memory/memory.py @ 1689:a40124e03baf
core (memory): catch exceptions.UnknownEntityError in getMainResource
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Nov 2015 17:00:18 +0100 |
parents | 373ce871b0f3 |
children | 35426d58471c |
comparison
equal
deleted
inserted
replaced
1688:59a94105b138 | 1689:a40124e03baf |
---|---|
563 @param entity_jid: bare jid of the entit | 563 @param entity_jid: bare jid of the entit |
564 @param profile_key: %(doc_profile_key)s | 564 @param profile_key: %(doc_profile_key)s |
565 return (list[unicode]): list of resources | 565 return (list[unicode]): list of resources |
566 | 566 |
567 @raise exceptions.UnknownEntityError: if entity is not in cache | 567 @raise exceptions.UnknownEntityError: if entity is not in cache |
568 @raise ValueError: entity_jid has a resource | |
568 """ | 569 """ |
569 if entity_jid.resource: | 570 if entity_jid.resource: |
570 raise ValueError("getAllResources must be used with a bare jid (got {})".format(entity_jid)) | 571 raise ValueError("getAllResources must be used with a bare jid (got {})".format(entity_jid)) |
571 profile_cache = self._getProfileCache(profile_key) | 572 profile_cache = self._getProfileCache(profile_key) |
572 try: | 573 try: |
616 try: | 617 try: |
617 if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key): | 618 if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key): |
618 return None # MUC rooms have no main resource | 619 return None # MUC rooms have no main resource |
619 except KeyError: # plugin not found | 620 except KeyError: # plugin not found |
620 pass | 621 pass |
621 resources = self.getAllResources(entity_jid, profile_key) | 622 try: |
623 resources = self.getAllResources(entity_jid, profile_key) | |
624 except exceptions.UnknownEntityError: | |
625 log.warning(u"Entity is not in cache, we can't find any resource") | |
626 return None | |
622 priority_resources = [] | 627 priority_resources = [] |
623 for resource in resources: | 628 for resource in resources: |
624 full_jid = copy.copy(entity_jid) | 629 full_jid = copy.copy(entity_jid) |
625 full_jid.resource = resource | 630 full_jid.resource = resource |
626 try: | 631 try: |