From ccb5e315fdcfd0605787d42aedd51b67e0ed5d2f Mon Sep 17 00:00:00 2001 From: chenxudong Date: Thu, 19 Jun 2025 15:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=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 --- src/install/Common.py | 7 ------- src/install/Uninstall.py | 9 +++++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/install/Common.py b/src/install/Common.py index b78b657..8c59d3a 100644 --- a/src/install/Common.py +++ b/src/install/Common.py @@ -1,7 +1,6 @@ import os import subprocess import sys -import zipfile from loguru import logger @@ -62,12 +61,6 @@ def start_service(service_name): return False -# def unzip_file(zip_file_path): -# new_path = get_resource_path(os.path.join('datas', 'mariadb.zip')) -# with zipfile.ZipFile(str(new_path), 'r') as zip_ref: -# zip_ref.extractall(zip_file_path) # 将文件解压到指定路径 - - def start_service_if_not_running(service_name): result = subprocess.run(['sc', 'query', service_name], capture_output=True, text=True) diff --git a/src/install/Uninstall.py b/src/install/Uninstall.py index 608d41d..130679b 100644 --- a/src/install/Uninstall.py +++ b/src/install/Uninstall.py @@ -1,3 +1,4 @@ +import os import shutil import subprocess import time @@ -17,14 +18,13 @@ def delete_service(service_name): pass -def start_uninstall(): +def start_uninstall(current_dir): logger.info("开始清理服务") service_names = {'ComacDatabase', 'ComacMariaDB'} for service in service_names: delete_service(service) logger.info("开始清理数据") - dirs = [rf'D:\database\logs', rf'D:\database\mariadb', rf'D:\database\jdk'] - for dir in dirs: + for dir in current_dir: shutil.rmtree(dir) logger.info('清理完成,10秒钟后自动退出') time.sleep(10) @@ -38,6 +38,7 @@ if __name__ == '__main__': # 弹出确认对话框 response = messagebox.askyesno("确认卸载", "确定卸载?") if response: - start_uninstall() + current_dir = os.getcwd() + start_uninstall(current_dir) else: logger.info("卸载取消")