From 8dbfc140ed16f4e4731597293f9710f6373b254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Thu, 31 Jan 2019 16:28:12 +0100 Subject: [PATCH] xep_0384: do things in session_bind only if lib is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `session_bind` is apparently loaded at about the same time as plugin_init, and exceptions will be raise if the library could not be loaded. Signed-off-by: Maxime “pep” Buquet --- plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index d6858d4..82c5b9e 100644 --- a/plugin.py +++ b/plugin.py @@ -144,7 +144,7 @@ class XEP_0384(BasePlugin): if not self.backend_loaded: log.info("xep_0384 cannot be loaded as the backend omemo library " "is not available") - return None + raise PluginCouldNotLoad if not self.data_dir: log.info("xep_0384 canoot be loaded as there is not data directory " @@ -183,9 +183,10 @@ class XEP_0384(BasePlugin): self.xmpp['xep_0163'].remove_interest(OMEMO_DEVICES_NS) def session_bind(self, _jid): - self.xmpp['xep_0163'].add_interest(OMEMO_DEVICES_NS) - asyncio.ensure_future(self._set_device_list()) - asyncio.ensure_future(self._publish_bundle()) + if self.backend_loaded: + self.xmpp['xep_0163'].add_interest(OMEMO_DEVICES_NS) + asyncio.ensure_future(self._set_device_list()) + asyncio.ensure_future(self._publish_bundle()) def my_device_id(self) -> int: return self._device_id