tools (common/dynamic_import): log a warning if bridge can't be imported

This commit is contained in:
Goffi 2020-06-01 11:14:20 +02:00
commit 7000fcda34

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python3
# SàT: a XMPP
# SàT: an XMPP client
# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
@ -20,6 +19,10 @@
""" tools dynamic import """
from importlib import import_module
from sat.core.log import getLogger
log = getLogger(__name__)
def bridge(name, module_path="sat.bridge"):
@ -34,6 +37,7 @@ def bridge(name, module_path="sat.bridge"):
except ImportError:
try:
bridge_module = import_module(module_path + "." + name + "_bridge")
except ImportError:
except ImportError as e:
log.warning(f"Can't import bridge {name!r}: {e}")
bridge_module = None
return bridge_module