Added many tools
This commit is contained in:
@@ -2,9 +2,12 @@ from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import pkgutil
|
||||
import logging
|
||||
|
||||
import tools as tools_pkg
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def load_all_tools():
|
||||
"""
|
||||
@@ -12,11 +15,36 @@ def load_all_tools():
|
||||
|
||||
Imports all modules inside /tools so they register
|
||||
themselves into the registry.
|
||||
|
||||
Safe version:
|
||||
- isolates import failures per module
|
||||
- logs instead of crashing system boot
|
||||
"""
|
||||
|
||||
for module in pkgutil.iter_modules(
|
||||
tools_pkg.__path__
|
||||
):
|
||||
importlib.import_module(
|
||||
f"tools.{module.name}"
|
||||
)
|
||||
loaded = 0
|
||||
failed = 0
|
||||
|
||||
for module in pkgutil.iter_modules(tools_pkg.__path__):
|
||||
module_name = f"tools.{module.name}"
|
||||
|
||||
try:
|
||||
importlib.import_module(module_name)
|
||||
loaded += 1
|
||||
|
||||
logger.info(f"[TOOLS] Loaded: {module_name}")
|
||||
|
||||
except Exception as e:
|
||||
failed += 1
|
||||
|
||||
logger.exception(
|
||||
f"[TOOLS] Failed to load {module_name}: {e}"
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"[TOOLS] Discovery complete: loaded={loaded}, failed={failed}"
|
||||
)
|
||||
|
||||
return {
|
||||
"loaded": loaded,
|
||||
"failed": failed
|
||||
}
|
||||
Reference in New Issue
Block a user
