fix
This commit is contained in:
@@ -17,12 +17,22 @@ sys.path.insert(0, str(current_dir))
|
||||
|
||||
# 导入核心模块
|
||||
try:
|
||||
from utils.logger import get_logger
|
||||
from utils.jsonrpc import create_response_handler, create_progress_reporter
|
||||
from config import get_config
|
||||
from python_core.utils.logger import get_logger
|
||||
from python_core.utils.jsonrpc import create_response_handler, create_progress_reporter
|
||||
from python_core.config import get_config
|
||||
except ImportError as e:
|
||||
print(f"ERROR: Failed to import core modules: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
# 尝试备用导入方式
|
||||
try:
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from utils.logger import get_logger
|
||||
from utils.jsonrpc import create_response_handler, create_progress_reporter
|
||||
from config import get_config
|
||||
except ImportError as e2:
|
||||
print(f"ERROR: Failed to import with backup method: {e2}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# 模块映射表
|
||||
MODULE_MAP = {
|
||||
@@ -84,7 +94,11 @@ def load_module_function(module_name, function_name):
|
||||
module_path = module_name
|
||||
|
||||
# 导入模块
|
||||
module = __import__(f"python_core.{module_path}", fromlist=[function_name])
|
||||
try:
|
||||
module = __import__(f"python_core.{module_path}", fromlist=[function_name])
|
||||
except ImportError:
|
||||
# 备用导入方式
|
||||
module = __import__(module_path, fromlist=[function_name])
|
||||
|
||||
# 获取函数
|
||||
if hasattr(module, function_name):
|
||||
|
||||
Reference in New Issue
Block a user