From 5cdf9d752fe0aa2ba1326150cd241d2ecfb9d4b4 Mon Sep 17 00:00:00 2001 From: li-xiaochen <397721316@qq.com> Date: Sat, 28 Dec 2024 20:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=9D=E8=B5=96=E6=97=B6=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- launcher/webview/api.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/launcher/webview/api.py b/launcher/webview/api.py index ac440c8..a869430 100644 --- a/launcher/webview/api.py +++ b/launcher/webview/api.py @@ -125,18 +125,24 @@ class Api: os._exit(0) def rm_site_packages(self): - site_packages_path = Path("./python/Lib/site-packages") - if site_packages_path.exists(): - rmtree(site_packages_path) - return "site-packages目录移除成功" - return "python\\Lib\\site-packages目录不存在" + try: + site_packages_path = Path("./python/Lib/site-packages") + if site_packages_path.exists(): + rmtree(site_packages_path) + return "site-packages目录移除成功" + return "python\\Lib\\site-packages目录不存在" + except Exception as e: + return repr(e) def rm_python_scripts(self): - python_scripts_path = Path("./python/Scripts") - if python_scripts_path.exists(): - rmtree(python_scripts_path) - return "Scripts目录移除成功" - return "python\\Scripts目录不存在" + try: + python_scripts_path = Path("./python/Scripts") + if python_scripts_path.exists(): + rmtree(python_scripts_path) + return "Scripts目录移除成功" + return "python\\Scripts目录不存在" + except Exception as e: + return repr(e) def run(self, command, cwd=None): command = command_list[command]