ErisPulse 1.1.1__py3-none-any.whl → 1.1.3__py3-none-any.whl
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/__init__.py +66 -52
- ErisPulse/adapter.py +1 -1
- {erispulse-1.1.1.dist-info → erispulse-1.1.3.dist-info}/METADATA +1 -1
- {erispulse-1.1.1.dist-info → erispulse-1.1.3.dist-info}/RECORD +7 -7
- {erispulse-1.1.1.dist-info → erispulse-1.1.3.dist-info}/WHEEL +0 -0
- {erispulse-1.1.1.dist-info → erispulse-1.1.3.dist-info}/entry_points.txt +0 -0
- {erispulse-1.1.1.dist-info → erispulse-1.1.3.dist-info}/top_level.txt +0 -0
ErisPulse/__init__.py
CHANGED
|
@@ -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,119 @@ 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
|
+
if hasattr(moduleObj.Main, "register_adapters"):
|
|
140
|
+
try:
|
|
141
|
+
adapters = moduleObj.Main.register_adapters()
|
|
142
|
+
if isinstance(adapters, dict):
|
|
143
|
+
for platform_name, adapter_class in adapters.items():
|
|
144
|
+
sdk.adapter.register(platform_name, adapter_class)
|
|
145
|
+
logger.info(f"模块 {meta_name} 注册了适配器: {platform_name}")
|
|
146
|
+
except Exception as e:
|
|
147
|
+
logger.error(f"模块 {meta_name} 注册适配器失败: {e}")
|
|
148
|
+
|
|
149
|
+
# ==== 存储模块信息到数据库 ====
|
|
131
150
|
all_modules_info = {}
|
|
132
151
|
for module_name in sdkInstalledModuleNames:
|
|
133
|
-
moduleObj =
|
|
152
|
+
moduleObj = module_objs[module_name]
|
|
134
153
|
moduleInfo: dict = moduleObj.moduleInfo
|
|
135
154
|
|
|
136
|
-
|
|
137
|
-
mods.
|
|
155
|
+
meta_name = moduleInfo.get("meta", {}).get("name", None)
|
|
156
|
+
module_info = mods.get_module(meta_name)
|
|
157
|
+
mods.set_module(meta_name, {
|
|
138
158
|
"status": True,
|
|
139
159
|
"info": moduleInfo
|
|
140
160
|
})
|
|
141
161
|
logger.debug("所有模块信息已加载并存储到数据库")
|
|
142
162
|
|
|
163
|
+
# ==== 实例化 Main 类并挂载到 sdk ====
|
|
164
|
+
logger.debug("[Init] 开始实例化模块 Main 类...")
|
|
143
165
|
for module_name in sdkInstalledModuleNames:
|
|
144
|
-
moduleObj =
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
moduleObj = module_objs[module_name]
|
|
167
|
+
meta_name = moduleObj.moduleInfo["meta"]["name"]
|
|
168
|
+
|
|
169
|
+
module_status = mods.get_module_status(meta_name)
|
|
147
170
|
if not module_status:
|
|
148
171
|
continue
|
|
149
172
|
|
|
150
173
|
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}")
|
|
174
|
+
setattr(moduleMain, "moduleInfo", moduleObj.moduleInfo)
|
|
175
|
+
setattr(sdk, meta_name, moduleMain)
|
|
176
|
+
logger.debug(f"模块 {meta_name} 正在初始化")
|
|
164
177
|
|
|
165
178
|
except Exception as e:
|
|
166
179
|
raiserr.InitError(f"sdk初始化失败: {e}", exit=True)
|
|
167
180
|
|
|
181
|
+
|
|
168
182
|
sdk.init = init
|
ErisPulse/adapter.py
CHANGED
|
@@ -112,7 +112,7 @@ class AdapterManager:
|
|
|
112
112
|
retry_count += 1
|
|
113
113
|
sdk.logger.error(f"平台 {platform} 启动失败(第{retry_count}次重试): {e}")
|
|
114
114
|
try:
|
|
115
|
-
await adapter.
|
|
115
|
+
await adapter.shutdown()
|
|
116
116
|
except Exception as stop_err:
|
|
117
117
|
sdk.logger.warning(f"停止适配器失败: {stop_err}")
|
|
118
118
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ErisPulse
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
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,13 +1,13 @@
|
|
|
1
|
-
ErisPulse/__init__.py,sha256=
|
|
1
|
+
ErisPulse/__init__.py,sha256=E3HUelqdyAnmi6soRn41TX7NM-vC9Nh2LjvrsqOH-aQ,7769
|
|
2
2
|
ErisPulse/__main__.py,sha256=-UdhsYP_X7EagomCjo73Y_qQdXwtMbDS5KoOSrI-OcU,32181
|
|
3
|
-
ErisPulse/adapter.py,sha256=
|
|
3
|
+
ErisPulse/adapter.py,sha256=9AaUrCNQ6UwN3rE7Tqdbl2mxIbOtiLQGcEm10mcKkEw,5017
|
|
4
4
|
ErisPulse/db.py,sha256=cd2AUfm-ZPzXlU8PLKK23QGd6VF0eSgYQl9dyRRpl_Y,4425
|
|
5
5
|
ErisPulse/logger.py,sha256=HIQMYD75K-PL4IETMlm7V6Eyg0ussZ11_riEw5E5a08,5899
|
|
6
6
|
ErisPulse/mods.py,sha256=M9XQWUQYNZ11m845hxbewBAauWXnysy-aOdLwb5xy_M,3312
|
|
7
7
|
ErisPulse/raiserr.py,sha256=z8BigWkVrBE9dD_dJa5np2YYREwdugyWXKE4_-LEO_Q,2616
|
|
8
8
|
ErisPulse/util.py,sha256=b9TqyRZKkpclN2fkHmWqBl3lnBMnUbucMvKvbqD5Ws8,2541
|
|
9
|
-
erispulse-1.1.
|
|
10
|
-
erispulse-1.1.
|
|
11
|
-
erispulse-1.1.
|
|
12
|
-
erispulse-1.1.
|
|
13
|
-
erispulse-1.1.
|
|
9
|
+
erispulse-1.1.3.dist-info/METADATA,sha256=4rCX2VPQTs9GuYgXNhUsE-N-nJZN8I8CBfPuEOiroxE,2282
|
|
10
|
+
erispulse-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
erispulse-1.1.3.dist-info/entry_points.txt,sha256=AjKvOdYR7QGXVpEJhjUYUwV2JluE4lm9vNbknC3hjOM,155
|
|
12
|
+
erispulse-1.1.3.dist-info/top_level.txt,sha256=Lm_qtkVvNJR8_dXh_qEDdl_12cZGpic-i4HUlVVUMZc,10
|
|
13
|
+
erispulse-1.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|