ErisPulse 1.1.2__tar.gz → 1.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/__init__.py +64 -52
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/PKG-INFO +1 -1
- {erispulse-1.1.2 → erispulse-1.1.4}/PKG-INFO +1 -1
- {erispulse-1.1.2 → erispulse-1.1.4}/pyproject.toml +1 -1
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/__main__.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/adapter.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/db.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/logger.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/mods.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/raiserr.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse/util.py +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/SOURCES.txt +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/dependency_links.txt +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/entry_points.txt +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/requires.txt +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/ErisPulse.egg-info/top_level.txt +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/README.md +0 -0
- {erispulse-1.1.2 → erispulse-1.1.4}/setup.cfg +0 -0
|
@@ -49,6 +49,8 @@ def init():
|
|
|
49
49
|
sdkInstalledModuleNames: list[str] = []
|
|
50
50
|
disabledModules: list[str] = []
|
|
51
51
|
|
|
52
|
+
# ==== 扫描模块并收集基本信息 ====
|
|
53
|
+
module_objs = {} # {module_name: moduleObj}
|
|
52
54
|
for module_name in TempModules:
|
|
53
55
|
try:
|
|
54
56
|
moduleObj = __import__(module_name)
|
|
@@ -62,107 +64,117 @@ def init():
|
|
|
62
64
|
logger.warning(f"模块 {module_name} 缺少 'Main' 类.")
|
|
63
65
|
continue
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
68
|
+
module_info = mods.get_module(meta_name)
|
|
66
69
|
if module_info is None:
|
|
67
70
|
module_info = {
|
|
68
71
|
"status": True,
|
|
69
72
|
"info": moduleObj.moduleInfo
|
|
70
73
|
}
|
|
71
|
-
mods.set_module(
|
|
72
|
-
logger.info(f"模块 {
|
|
74
|
+
mods.set_module(meta_name, module_info)
|
|
75
|
+
logger.info(f"模块 {meta_name} 信息已初始化并存储到数据库")
|
|
73
76
|
|
|
74
77
|
if not module_info.get('status', True):
|
|
75
78
|
disabledModules.append(module_name)
|
|
76
|
-
logger.warning(f"模块 {
|
|
79
|
+
logger.warning(f"模块 {meta_name} 已禁用,跳过加载")
|
|
77
80
|
continue
|
|
78
81
|
|
|
79
|
-
required_deps = moduleObj.moduleInfo.get("dependencies",
|
|
82
|
+
required_deps = moduleObj.moduleInfo.get("dependencies", {}).get("requires", [])
|
|
80
83
|
missing_required_deps = [dep for dep in required_deps if dep not in TempModules]
|
|
81
84
|
if missing_required_deps:
|
|
82
85
|
logger.error(f"模块 {module_name} 缺少必需依赖: {missing_required_deps}")
|
|
83
86
|
raiserr.MissingDependencyError(f"模块 {module_name} 缺少必需依赖: {missing_required_deps}")
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if
|
|
91
|
-
available_deps
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
elif dep in TempModules:
|
|
95
|
-
available_optional_deps.append(dep)
|
|
96
|
-
|
|
97
|
-
if available_optional_deps:
|
|
98
|
-
logger.info(f"模块 {module_name} 加载了部分可选依赖: {available_optional_deps}")
|
|
99
|
-
else:
|
|
100
|
-
logger.warning(f"模块 {module_name} 缺少所有可选依赖: {optional_deps}")
|
|
88
|
+
optional_deps = moduleObj.moduleInfo.get("dependencies", {}).get("optional", [])
|
|
89
|
+
available_optional_deps = []
|
|
90
|
+
for dep in optional_deps:
|
|
91
|
+
if isinstance(dep, list):
|
|
92
|
+
available_deps = [d for d in dep if d in TempModules]
|
|
93
|
+
if available_deps:
|
|
94
|
+
available_optional_deps.extend(available_deps)
|
|
95
|
+
elif dep in TempModules:
|
|
96
|
+
available_optional_deps.append(dep)
|
|
101
97
|
|
|
98
|
+
if optional_deps and not available_optional_deps:
|
|
99
|
+
logger.warning(f"模块 {module_name} 缺少所有可选依赖: {optional_deps}")
|
|
100
|
+
|
|
101
|
+
module_objs[module_name] = moduleObj
|
|
102
102
|
sdkInstalledModuleNames.append(module_name)
|
|
103
|
+
|
|
103
104
|
except Exception as e:
|
|
104
105
|
logger.warning(f"模块 {module_name} 加载失败: {e}")
|
|
105
106
|
continue
|
|
106
107
|
|
|
108
|
+
# ==== 构建依赖图并进行拓扑排序 ====
|
|
107
109
|
sdkModuleDependencies = {}
|
|
108
110
|
for module_name in sdkInstalledModuleNames:
|
|
109
|
-
moduleObj =
|
|
110
|
-
|
|
111
|
+
moduleObj = module_objs[module_name]
|
|
112
|
+
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
113
|
+
|
|
114
|
+
req_deps = moduleObj.moduleInfo.get("dependencies", {}).get("requires", [])
|
|
115
|
+
opt_deps = moduleObj.moduleInfo.get("dependencies", {}).get("optional", [])
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
moduleDependecies.extend(available_optional_deps)
|
|
117
|
+
available_optional_deps = [dep for dep in opt_deps if dep in sdkInstalledModuleNames]
|
|
118
|
+
deps = req_deps + available_optional_deps
|
|
115
119
|
|
|
116
|
-
for dep in
|
|
120
|
+
for dep in deps:
|
|
117
121
|
if dep in disabledModules:
|
|
118
|
-
logger.warning(f"模块 {
|
|
122
|
+
logger.warning(f"模块 {meta_name} 的依赖模块 {dep} 已禁用,跳过加载")
|
|
119
123
|
continue
|
|
120
124
|
|
|
121
|
-
if not all(dep in sdkInstalledModuleNames for dep in
|
|
122
|
-
raiserr.InvalidDependencyError(
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
sdkModuleDependencies[module_name] = moduleDependecies
|
|
125
|
+
if not all(dep in sdkInstalledModuleNames for dep in deps):
|
|
126
|
+
raiserr.InvalidDependencyError(f"模块 {meta_name} 的依赖无效: {deps}")
|
|
127
|
+
sdkModuleDependencies[module_name] = deps
|
|
126
128
|
|
|
127
129
|
sdkInstalledModuleNames: list[str] = sdk.util.topological_sort(
|
|
128
130
|
sdkInstalledModuleNames, sdkModuleDependencies, raiserr.CycleDependencyError
|
|
129
131
|
)
|
|
130
132
|
|
|
133
|
+
# ==== 注册适配器 ====
|
|
134
|
+
logger.debug("[Init] 开始注册适配器...")
|
|
135
|
+
for module_name in sdkInstalledModuleNames:
|
|
136
|
+
moduleObj = module_objs[module_name]
|
|
137
|
+
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
if hasattr(moduleObj, "adapterInfo") and isinstance(moduleObj.adapterInfo, dict):
|
|
141
|
+
for platform_name, adapter_class in moduleObj.adapterInfo.items():
|
|
142
|
+
sdk.adapter.register(platform_name, adapter_class)
|
|
143
|
+
logger.info(f"模块 {meta_name} 注册了适配器: {platform_name}")
|
|
144
|
+
except Exception as e:
|
|
145
|
+
logger.error(f"模块 {meta_name} 注册适配器失败: {e}")
|
|
146
|
+
|
|
147
|
+
# ==== 存储模块信息到数据库 ====
|
|
131
148
|
all_modules_info = {}
|
|
132
149
|
for module_name in sdkInstalledModuleNames:
|
|
133
|
-
moduleObj =
|
|
150
|
+
moduleObj = module_objs[module_name]
|
|
134
151
|
moduleInfo: dict = moduleObj.moduleInfo
|
|
135
152
|
|
|
136
|
-
|
|
137
|
-
mods.
|
|
153
|
+
meta_name = moduleInfo.get("meta", {}).get("name", None)
|
|
154
|
+
module_info = mods.get_module(meta_name)
|
|
155
|
+
mods.set_module(meta_name, {
|
|
138
156
|
"status": True,
|
|
139
157
|
"info": moduleInfo
|
|
140
158
|
})
|
|
141
159
|
logger.debug("所有模块信息已加载并存储到数据库")
|
|
142
160
|
|
|
161
|
+
# ==== 实例化 Main 类并挂载到 sdk ====
|
|
162
|
+
logger.debug("[Init] 开始实例化模块 Main 类...")
|
|
143
163
|
for module_name in sdkInstalledModuleNames:
|
|
144
|
-
moduleObj =
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
moduleObj = module_objs[module_name]
|
|
165
|
+
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
166
|
+
|
|
167
|
+
module_status = mods.get_module_status(meta_name)
|
|
147
168
|
if not module_status:
|
|
148
169
|
continue
|
|
149
170
|
|
|
150
171
|
moduleMain = moduleObj.Main(sdk)
|
|
151
|
-
setattr(moduleMain, "moduleInfo", moduleInfo)
|
|
152
|
-
setattr(sdk,
|
|
153
|
-
logger.debug(f"模块 {
|
|
154
|
-
|
|
155
|
-
if hasattr(moduleMain, "register_adapters"):
|
|
156
|
-
try:
|
|
157
|
-
adapters = moduleMain.register_adapters()
|
|
158
|
-
if isinstance(adapters, dict):
|
|
159
|
-
for platform_name, adapter_class in adapters.items():
|
|
160
|
-
sdk.adapter.register(platform_name, adapter_class)
|
|
161
|
-
logger.info(f"模块 {moduleInfo['meta']['name']} 注册了适配器: {platform_name}")
|
|
162
|
-
except Exception as e:
|
|
163
|
-
logger.error(f"注册适配器失败: {e}")
|
|
172
|
+
setattr(moduleMain, "moduleInfo", moduleObj.moduleInfo)
|
|
173
|
+
setattr(sdk, meta_name, moduleMain)
|
|
174
|
+
logger.debug(f"模块 {meta_name} 正在初始化")
|
|
164
175
|
|
|
165
176
|
except Exception as e:
|
|
166
177
|
raiserr.InitError(f"sdk初始化失败: {e}", exit=True)
|
|
167
178
|
|
|
179
|
+
|
|
168
180
|
sdk.init = init
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。
|
|
5
5
|
Author-email: "艾莉丝·格雷拉特(WSu2059)" <wsu2059@qq.com>, runoneall <runoobsteve@gmail.com>
|
|
6
6
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: ErisPulse 是一个模块化、可扩展的异步 Python SDK 框架,主要用于构建高效、可维护的机器人应用程序。
|
|
5
5
|
Author-email: "艾莉丝·格雷拉特(WSu2059)" <wsu2059@qq.com>, runoneall <runoobsteve@gmail.com>
|
|
6
6
|
Classifier: Development Status :: 5 - Production/Stable
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|