From 541e4189461de2c6604db8b5ce7d48d88d00ffb8 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 16 Feb 2023 13:40:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96applets-dbeaver?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E9=A9=B1=E5=8A=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/applets/dbeaver/app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/terminal/applets/dbeaver/app.py b/apps/terminal/applets/dbeaver/app.py index 710794a98..e9a7dff4d 100644 --- a/apps/terminal/applets/dbeaver/app.py +++ b/apps/terminal/applets/dbeaver/app.py @@ -1,4 +1,7 @@ +import os import time +import win32api +import shutil from pywinauto import Application @@ -22,6 +25,13 @@ class AppletApplication(BaseApplication): self.pid = None self.app = None + def launch(self): + win_user_name = win32api.GetUserName() + src_driver = os.path.join(os.path.dirname(self.path), 'drivers') + dest_driver = r'C:\Users\%s\AppData\Roaming\DBeaverData\drivers' % win_user_name + if not os.path.exists(dest_driver): + shutil.copytree(src_driver, dest_driver, dirs_exist_ok=True) + def _get_exec_params(self): driver = getattr(self, 'driver', self.protocol) params_string = f'name={self.name}|' \ @@ -50,6 +60,7 @@ class AppletApplication(BaseApplication): return self._get_exec_params() def run(self): + self.launch() self.app = Application(backend='uia') function = getattr(self, '_get_%s_exec_params' % self.protocol, None) @@ -57,7 +68,8 @@ class AppletApplication(BaseApplication): params = self._get_exec_params() else: params = function() - self.app.start('%s -con %s' % (self.path, params), wait_for_idle=False) + exec_string = '%s -con %s' % (self.path, params) + self.app.start(exec_string, wait_for_idle=False) self.pid = self.app.process def wait(self):