From 45c0a382c99c6f58977b0342972b2e914c3b3026 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 17 Jan 2021 15:17:14 +0100 Subject: [PATCH] [core/module] fix load error when no user module exists --- bumblebee_status/core/module.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bumblebee_status/core/module.py b/bumblebee_status/core/module.py index 145d16d..9239a49 100644 --- a/bumblebee_status/core/module.py +++ b/bumblebee_status/core/module.py @@ -46,10 +46,13 @@ def load(module_name, config=core.config.Config([]), theme=None): log.debug("importing {} from contrib".format(module_short)) 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 try: log.warning("failed to import {} from system: {}".format(module_short, e)) mod = importlib.machinery.SourceFileLoader("modules.{}".format(module_short), - os.path.expanduser("~/.config/bumblebee-status/modules/{}.py".format(module_short))).load_module() + os.path.expanduser(usermod)).load_module() log.debug("importing {} from user".format(module_short)) return getattr(mod, "Module")(config, theme) except ImportError as e: