From d71374ca8a8d8fcc186391172ff2e1a405a9198d Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 21 Mar 2024 11:35:14 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/models/applet/host.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/terminal/models/applet/host.py b/apps/terminal/models/applet/host.py index 96eeee56a..7df9efe2f 100644 --- a/apps/terminal/models/applet/host.py +++ b/apps/terminal/models/applet/host.py @@ -159,24 +159,21 @@ class AppletHostDeployment(JMSBaseModel): manager.run() def install_applet(self, applet_id, **kwargs): - from ...automations.deploy_applet_host import DeployAppletHostManager - from .applet import Applet - if applet_id: - applet = Applet.objects.get(id=applet_id) - else: - applet = None - manager = DeployAppletHostManager(self, applet=applet) + manager = self.create_deploy_manager(applet_id, **kwargs) manager.install_applet(**kwargs) def uninstall_applet(self, applet_id, **kwargs): + manager = self.create_deploy_manager(applet_id, **kwargs) + manager.uninstall_applet(**kwargs) + + def create_deploy_manager(self, applet_id, **kwargs): from ...automations.deploy_applet_host import DeployAppletHostManager from .applet import Applet if applet_id: applet = Applet.objects.get(id=applet_id) else: applet = None - manager = DeployAppletHostManager(self, applet=applet) - manager.uninstall_applet(**kwargs) + return DeployAppletHostManager(self, applet=applet) def save_task(self, task): self.task = task