[core/module] fix failing unit test
wrong error handling again
This commit is contained in:
parent
beca26c2bf
commit
a27c284869
1 changed files with 10 additions and 12 deletions
|
@ -17,8 +17,6 @@ except Exception as e:
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
"""Loads a module by name
|
"""Loads a module by name
|
||||||
|
|
||||||
:param module_name: Name of the module to load
|
: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)
|
return getattr(mod, "Module")(config, theme)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
usermod = os.path.expanduser("~/.config/bumblebee-status/modules/{}.py".format(module_short))
|
usermod = os.path.expanduser("~/.config/bumblebee-status/modules/{}.py".format(module_short))
|
||||||
if not os.path.exists(usermod):
|
if os.path.exists(usermod):
|
||||||
raise e
|
|
||||||
try:
|
try:
|
||||||
log.warning("failed to import {} from system: {}".format(module_short, e))
|
log.warning("failed to import {} from system: {}".format(module_short, e))
|
||||||
mod = importlib.machinery.SourceFileLoader("modules.{}".format(module_short),
|
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))
|
log.debug("importing {} from user".format(module_short))
|
||||||
return getattr(mod, "Module")(config, theme)
|
return getattr(mod, "Module")(config, theme)
|
||||||
except ImportError as e:
|
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")
|
return Error(config=config, module=module_name, error="unable to load module")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue