[core/module] fix failing unit test

wrong error handling again
This commit is contained in:
tobi-wan-kenobi 2021-01-17 15:29:44 +01:00
parent beca26c2bf
commit a27c284869

View file

@ -17,8 +17,6 @@ except Exception as e:
log = logging.getLogger(__name__)
import sys
"""Loads a module by name
:param module_name: Name of the module to load
@ -47,8 +45,7 @@ def load(module_name, config=core.config.Config([]), theme=None):
return getattr(mod, "Module")(config, theme)
except ImportError as e:
usermod = os.path.expanduser("~/.config/bumblebee-status/modules/{}.py".format(module_short))
if not os.path.exists(usermod):
raise e
if os.path.exists(usermod):
try:
log.warning("failed to import {} from system: {}".format(module_short, e))
mod = importlib.machinery.SourceFileLoader("modules.{}".format(module_short),
@ -56,7 +53,8 @@ def load(module_name, config=core.config.Config([]), theme=None):
log.debug("importing {} from user".format(module_short))
return getattr(mod, "Module")(config, theme)
except ImportError as e:
log.fatal("failed to import {}: {}".format(module_short, e))
log.fatal("import failed: {}".format(e))
log.fatal("failed to import {}".format(module_short))
return Error(config=config, module=module_name, error="unable to load module")