Don't crash when plugins fail to load.
This commit is contained in:
parent
3e8c2f94ff
commit
78130b4f7f
|
@ -10,8 +10,8 @@ from . import (
|
|||
model,
|
||||
plugins,
|
||||
pods, # noqa: F401 this is imported for side effects
|
||||
vt100,
|
||||
shell,
|
||||
vt100,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -240,15 +240,15 @@ def link(
|
|||
if scope.component.type == model.Kind.LIB:
|
||||
w.build(out, "ar", objs, implicit=res)
|
||||
else:
|
||||
whileLibs = collectInjectedLibs(scope)
|
||||
wholeLibs = collectInjectedLibs(scope)
|
||||
libs = collectLibs(scope)
|
||||
w.build(
|
||||
out,
|
||||
"ld",
|
||||
objs + whileLibs + libs,
|
||||
objs + wholeLibs + libs,
|
||||
variables={
|
||||
"objs": " ".join(objs),
|
||||
"wholeLibs": " ".join(whileLibs),
|
||||
"wholeLibs": " ".join(wholeLibs),
|
||||
"libs": " ".join(libs),
|
||||
},
|
||||
implicit=res,
|
||||
|
|
|
@ -120,6 +120,8 @@ def usage(args: Optional[Args] = None):
|
|||
def error(msg: str) -> None:
|
||||
print(f"{vt100.RED}Error:{vt100.RESET} {msg}\n", file=sys.stderr)
|
||||
|
||||
def warning(msg: str) -> None:
|
||||
print(f"{vt100.YELLOW}Warning:{vt100.RESET} {msg}\n", file=sys.stderr)
|
||||
|
||||
@command("h", "help", "Show this help message")
|
||||
def helpCmd(args: Args):
|
||||
|
|
|
@ -15,11 +15,15 @@ def load(path: str):
|
|||
|
||||
if not spec or not spec.loader:
|
||||
_logger.error(f"Failed to load plugin {path}")
|
||||
return None
|
||||
|
||||
module = importlib.module_from_spec(spec)
|
||||
sys.modules["plugin"] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
try:
|
||||
spec.loader.exec_module(module)
|
||||
except Exception as e:
|
||||
_logger.error(f"Failed to load plugin {path}: {e}")
|
||||
cli.warning(f"Plugin {path} loading skipped due to error")
|
||||
|
||||
|
||||
def loadAll():
|
||||
|
@ -35,6 +39,7 @@ def loadAll():
|
|||
|
||||
for dirname in paths:
|
||||
pluginDir = os.path.join(project.dirname(), dirname, const.META_DIR, "plugins")
|
||||
pluginDir = os.path.normpath(pluginDir)
|
||||
initFile = os.path.join(pluginDir, "__init__.py")
|
||||
|
||||
if os.path.isfile(initFile):
|
||||
|
|
Loading…
Reference in a new issue