-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
78 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,48 @@ | ||
# 想要实现但是没有实现的功能 | ||
`pluginsystem.py` | ||
|
||
```python | ||
# TODO:修不起这个bug了,谁爱修谁修。。。。。。。。。。。。。。。 | ||
|
||
for plugin_file in confi["plugins"]["others_plugin"]: | ||
plugin_name = plugin_file | ||
try: | ||
if plugin_file is not None: | ||
mlogger.info(f"loading plugin{plugin_file}") | ||
path = os.path.normpath(plugin_file) | ||
if os.path.isdir(plugin_name): | ||
spec = importlib.util.spec_from_file_location(os.path.dirname(path), "__init__.py") | ||
else: | ||
spec = importlib.util.spec_from_file_location(os.path.dirname(path), os.path.basename(path)) | ||
if spec is None: | ||
mlogger.error(f"no modle on {path}") | ||
continue | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
# 检查是否实现了主方法 | ||
if not hasattr(module, "Plugin_Main"): | ||
raise plugin_errors.NoMainMather("函数未实现主方法或者主方法名称错误") | ||
plugin_main_class: plugin_main.Plugin_Main = module.Plugin_Main | ||
|
||
# 获取插件类型 | ||
if plugin_main_class.plugin_type() == "message": | ||
self.message_plugin_list.append(plugin_main_class) | ||
elif plugin_main_class.plugin_type() == "analyzer": | ||
self.analyzer_plugin_list.append(plugin_main_class) | ||
else: | ||
raise plugin_errors.PluginTypeError("未知的插件类型,该不会是插件吃了金克拉了吧?") | ||
for plugin_file in confi["plugins"]["others_plugin"]: | ||
plugin_name = plugin_file | ||
try: | ||
if plugin_file is not None: | ||
mlogger.info(f"loading plugin{plugin_file}") | ||
path = os.path.normpath(plugin_file) | ||
if os.path.isdir(plugin_name): | ||
spec = importlib.util.spec_from_file_location(os.path.dirname(path), "__init__.py") | ||
else: | ||
spec = importlib.util.spec_from_file_location(os.path.dirname(path), os.path.basename(path)) | ||
if spec is None: | ||
mlogger.error(f"no modle on {path}") | ||
continue | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
# 检查是否实现了主方法 | ||
if not hasattr(module, "Plugin_Main"): | ||
raise plugin_errors.NoMainMather("函数未实现主方法或者主方法名称错误") | ||
plugin_main_class: plugin_main.Plugin_Main = module.Plugin_Main | ||
|
||
# 获取插件类型 | ||
if plugin_main_class.plugin_type() == "message": | ||
self.message_plugin_list.append(plugin_main_class) | ||
elif plugin_main_class.plugin_type() == "analyzer": | ||
self.analyzer_plugin_list.append(plugin_main_class) | ||
else: | ||
raise plugin_errors.PluginTypeError("未知的插件类型,该不会是插件吃了金克拉了吧?") | ||
|
||
# 注册插件cgi | ||
if plugin_main_class.sprit_cgi_support: | ||
if plugin_main_class.sprit_cgi_path: | ||
self.plugin_cgi_support[plugin_main_class.sprit_cgi_path] = plugin_main_class.cgi_face | ||
else: | ||
raise | ||
|
||
# 注册插件cgi | ||
if plugin_main_class.sprit_cgi_support: | ||
if plugin_main_class.sprit_cgi_path: | ||
self.plugin_cgi_support[plugin_main_class.sprit_cgi_path] = plugin_main_class.sprit_cgi | ||
else: | ||
raise | ||
# 注册js脚本 | ||
if plugin_main_class.plugin_js_sprit_support: | ||
self.plugin_js_support[plugin_main_class.plugin_name] = plugin_main_class.plugin_js_sprit | ||
except ImportError as e: | ||
mlogger.error(f"failed to import plugin {plugin_name:{str(e)}}") | ||
|
||
# 注册js脚本 | ||
if plugin_main_class.plugin_js_sprit_support: | ||
self.plugin_js_support[plugin_main_class.plugin_name] = plugin_main_class.plugin_js_sprit | ||
except ImportError as e: | ||
mlogger.error(f"failed to import plugin {plugin_name:{str(e)}}") | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ loglevel: INFO | |
#日志文件 | ||
logfile: | ||
open: 1 | ||
name: "latest-log" | ||
name: "latestlog" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
这个文件内定义全部的标准消息模板 | ||
所有的函数都应该又to_dict方法来将其转为字典,相反的这个函数能输出打包好的字典 | ||
别问我为啥,问就是不知道 | ||
""" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters