comparison sat/plugins/plugin_xep_0384.py @ 3142:cd90c24b2836

plugin XEP-0384: fixed exception catching on getItems
author Goffi <goffi@goffi.org>
date Wed, 29 Jan 2020 18:31:47 +0100
parents 9d0df638c8b4
children dcebc585c29f
comparison
equal deleted inserted replaced
3141:49962f9a238a 3142:cd90c24b2836
632 """ 632 """
633 if entity_jid is not None: 633 if entity_jid is not None:
634 assert not entity_jid.resource 634 assert not entity_jid.resource
635 try: 635 try:
636 items, metadata = yield self._p.getItems(client, entity_jid, NS_OMEMO_DEVICES) 636 items, metadata = yield self._p.getItems(client, entity_jid, NS_OMEMO_DEVICES)
637 except error.StanzaError as e: 637 except exceptions.NotFound:
638 if e.condition == 'item-not-found': 638 log.info(_("there is no node to handle OMEMO devices"))
639 log.info(_("there is no node to handle OMEMO devices")) 639 defer.returnValue(set())
640 defer.returnValue(set())
641 raise e
642 640
643 devices = self.parseDevices(items) 641 devices = self.parseDevices(items)
644 defer.returnValue(devices) 642 defer.returnValue(devices)
645 643
646 def setDevicesEb(self, failure_): 644 def setDevicesEb(self, failure_):
675 missing = set() 673 missing = set()
676 for device_id in devices_ids: 674 for device_id in devices_ids:
677 node = NS_OMEMO_BUNDLE.format(device_id=device_id) 675 node = NS_OMEMO_BUNDLE.format(device_id=device_id)
678 try: 676 try:
679 items, metadata = yield self._p.getItems(client, entity_jid, node) 677 items, metadata = yield self._p.getItems(client, entity_jid, node)
678 except exceptions.NotFound:
679 log.warning(_("Bundle missing for device {device_id}")
680 .format(device_id=device_id))
681 missing.add(device_id)
682 continue
680 except error.StanzaError as e: 683 except error.StanzaError as e:
681 if e.condition == "item-not-found": 684 log.warning(_("Can't get bundle for device {device_id}: {reason}")
682 log.warning(_("Bundle missing for device {device_id}") 685 .format(device_id=device_id, reason=e))
683 .format(device_id=device_id)) 686 continue
684 missing.add(device_id)
685 continue
686 else:
687 log.warning(_("Can't get bundle for device {device_id}: {reason}")
688 .format(device_id=device_id, reason=e))
689 continue
690 if not items: 687 if not items:
691 log.warning(_("no item found in node {node}, can't get public bundle " 688 log.warning(_("no item found in node {node}, can't get public bundle "
692 "for deviceĀ {device_id}").format(node=node, 689 "for deviceĀ {device_id}").format(node=node,
693 device_id=device_id)) 690 device_id=device_id))
694 continue 691 continue