[core/module] fix load error when no user module exists
This commit is contained in:
parent
21ded8f640
commit
45c0a382c9
1 changed files with 4 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue