Attempt at having more useful errors for plugin setup
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6675ab631c
commit
fe897a786e
1 changed files with 13 additions and 6 deletions
|
@ -32,14 +32,17 @@ from .stanza import Bundle, Devices, Device, Encrypted, Key, PreKeyPublic
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
HAS_OMEMO = True
|
||||
HAS_OMEMO = False
|
||||
HAS_OMEMO_BACKEND = False
|
||||
try:
|
||||
import omemo.exceptions
|
||||
from omemo import SessionManager, ExtendedPublicBundle, DefaultOTPKPolicy
|
||||
from omemo.util import generateDeviceID
|
||||
from omemo.implementations import JSONFileStorage
|
||||
from omemo.backends import Backend
|
||||
HAS_OMEMO = True
|
||||
from omemo_backend_signal import BACKEND as SignalBackend
|
||||
HAS_OMEMO_BACKEND = True
|
||||
except (ImportError,):
|
||||
class Backend:
|
||||
pass
|
||||
|
@ -50,8 +53,6 @@ except (ImportError,):
|
|||
class SignalBackend:
|
||||
pass
|
||||
|
||||
HAS_OMEMO = False
|
||||
|
||||
TRUE_VALUES = {True, 'true', '1'}
|
||||
PUBLISH_OPTIONS_NODE = 'http://jabber.org/protocol/pubsub#publish-options'
|
||||
PUBSUB_ERRORS = 'http://jabber.org/protocol/pubsub#errors'
|
||||
|
@ -186,15 +187,21 @@ class XEP_0384(BasePlugin):
|
|||
'omemo_backend': SignalBackend,
|
||||
}
|
||||
|
||||
backend_loaded = HAS_OMEMO
|
||||
backend_loaded = HAS_OMEMO and HAS_OMEMO_BACKEND
|
||||
|
||||
# OMEMO Bundles used for encryption
|
||||
bundles = {} # type: Dict[str, Dict[int, ExtendedPublicBundle]]
|
||||
|
||||
def plugin_init(self) -> None:
|
||||
if not self.backend_loaded:
|
||||
log.info("xep_0384 cannot be loaded as the backend omemo library "
|
||||
"is not available")
|
||||
log_str = ("xep_0384 cannot be loaded as the backend omemo library "
|
||||
"is not available. ")
|
||||
if not HAS_OMEMO_BACKEND:
|
||||
log_str += ("Make sure you have a python OMEMO backend "
|
||||
"(python-omemo-backend-signal) installed")
|
||||
else:
|
||||
log_str += "Make sure you have the python OMEMO library installed."
|
||||
log.error(log_str)
|
||||
raise PluginCouldNotLoad
|
||||
|
||||
if not self.data_dir:
|
||||
|
|
Loading…
Reference in a new issue