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]