From 3351740866e9969b5d5f9ae068189f11ae5ac1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 18 Mar 2023 15:58:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5dev=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=8F=92=E4=BB=B6namespace=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/pluginAPI.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/OlivOS/pluginAPI.py b/OlivOS/pluginAPI.py index 6dc0b9e6..f3ae3341 100644 --- a/OlivOS/pluginAPI.py +++ b/OlivOS/pluginAPI.py @@ -122,6 +122,7 @@ def run(self): # self.set_check_update() time.sleep(1) # 此处延迟用于在终端第一次启动时等待终端初始化,避免日志丢失,后续需要用异步(控制包流程)方案替代 self.load_plugin_list() + self.check_plugin_list() self.run_plugin_func(None, 'init_after') self.log(2, OlivOS.L10NAPI.getText('pluginAPI_0001', [self.Proc_name])) self.sendPluginList() @@ -300,16 +301,30 @@ def plugin_event_router(self, plugin_event, plugin_model, plugin_name): plugin_event.set_block() return + def check_plugin_list(self): + new_list = [] + for plugin_models_index_this in self.plugin_models_call_list: + if plugin_models_index_this in self.plugin_models_dict: + new_list.append(plugin_models_index_this) + else: + self.log(4, OlivOS.L10NAPI.getText('pluginAPI_0013', [ + plugin_models_index_this, + self.Proc_name, + 'namespace failed' + ])) + self.plugin_models_call_list = new_list + def run_plugin_func(self, plugin_event, func_name): for plugin_models_index_this in self.plugin_models_call_list: - if hasattr(self.plugin_models_dict[plugin_models_index_this]['model'].main.Event, func_name): + if plugin_models_index_this in self.plugin_models_dict: try: - getattr(self.plugin_models_dict[plugin_models_index_this]['model'].main.Event, func_name)( - plugin_event=plugin_event, Proc=self) - self.log(2, OlivOS.L10NAPI.getText('pluginAPI_0009', [ - self.plugin_models_dict[plugin_models_index_this]['name'], - func_name - ])) + if hasattr(self.plugin_models_dict[plugin_models_index_this]['model'].main.Event, func_name): + getattr(self.plugin_models_dict[plugin_models_index_this]['model'].main.Event, func_name)( + plugin_event=plugin_event, Proc=self) + self.log(2, OlivOS.L10NAPI.getText('pluginAPI_0009', [ + self.plugin_models_dict[plugin_models_index_this]['name'], + func_name + ])) except Exception as e: # traceback.print_exc() self.log(4, OlivOS.L10NAPI.getText('pluginAPI_0008', [ @@ -318,6 +333,12 @@ def run_plugin_func(self, plugin_event, func_name): str(e), traceback.format_exc() ])) + else: + self.log(4, OlivOS.L10NAPI.getText('pluginAPI_0013', [ + plugin_models_index_this, + self.Proc_name, + 'namespace failed' + ])) return def sendPluginList(self):