From 42ccbe7499b415be63be2c591afdad4587af68a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Wed, 4 Jul 2018 23:58:52 +0200 Subject: [PATCH] Dont fail if modules are not registered This is for Zeroconf so we dont have to test in GUI always for account != local Fixes #9229 --- gajim/common/connection.py | 6 +++++- gajim/common/helpers.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gajim/common/connection.py b/gajim/common/connection.py index 87b7d9a11..2de15bb0f 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -63,6 +63,7 @@ from gajim.common import gpg from gajim.common import passwords from gajim.common import i18n from gajim.common import idle +from gajim.common.helpers import ModuleMock from gajim.common.modules.entity_time import EntityTime from gajim.common.modules.software_version import SoftwareVersion from gajim.common.modules.ping import Ping @@ -179,7 +180,10 @@ class CommonConnection: app.ged.raise_event(event, self.name, data) def get_module(self, name): - return self._modules[name] + try: + return self._modules[name] + except KeyError: + return ModuleMock() def get_module_handlers(self): handlers = [] diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index ad7a1c7df..db6664aad 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -164,6 +164,14 @@ class LocalTimezone(tzinfo): class InvalidFormat(Exception): pass + +class ModuleMock: + def __getattr__(self, key): + def _mock(self, *args, **kwargs): + return + return _mock + + def decompose_jid(jidstring): user = None server = None