|
|
@@ -18,6 +18,8 @@ from tools.utils import save_all_proxy_ip_v3
|
|
|
|
|
|
import winreg
|
|
|
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
# 定义 Redis 安装程序路径
|
|
|
REDIS_INSTALLER_PATH = "Redis-x64-5.0.14.1.msi" # 替换为实际的安装程序路径
|
|
|
|
|
|
@@ -47,6 +49,12 @@ def get_resource_path(relative_path):
|
|
|
return os.path.join(base_path, relative_path)
|
|
|
|
|
|
|
|
|
+def get_dir_path(relative_path):
|
|
|
+ """获取资源文件路径"""
|
|
|
+ base_path = getattr(sys, '_MEIPASS', str(Path(__file__).parent.absolute()))
|
|
|
+ return Path(base_path, relative_path)
|
|
|
+
|
|
|
+
|
|
|
# 停止定时任务
|
|
|
def on_stop_time_button_click():
|
|
|
print(f"停止定时任务: {time.time()}")
|
|
|
@@ -234,10 +242,21 @@ class MainWindow(QMainWindow, Ui_menu):
|
|
|
# 获取项目当前路径
|
|
|
current_path = sys.path[0]
|
|
|
# 拼接文件夹路径
|
|
|
- folder_path = get_resource_path("results") # 假设文件夹名为 "results"
|
|
|
+ folder_path = get_dir_path("results") # 假设文件夹名为 "results"
|
|
|
+
|
|
|
+ # 判断文件夹是否存在,不存在则创建
|
|
|
+ if not folder_path.exists():
|
|
|
+ try:
|
|
|
+ folder_path.mkdir(parents=True, exist_ok=True)
|
|
|
+ print(f"文件夹 {folder_path} 已创建")
|
|
|
+ except Exception as e:
|
|
|
+ QMessageBox.critical(self, "Error", f"无法创建文件夹: {e}")
|
|
|
+ return
|
|
|
+
|
|
|
+ # 打开文件夹
|
|
|
try:
|
|
|
# 使用 QDesktopServices.openUrl 打开文件夹
|
|
|
- QDesktopServices.openUrl(QUrl.fromLocalFile(folder_path))
|
|
|
+ QDesktopServices.openUrl(QUrl.fromLocalFile(str(folder_path)))
|
|
|
except Exception as e:
|
|
|
QMessageBox.critical(self, "Error", f"无法打开文件夹: {e}")
|
|
|
|