|
|
@@ -1,4 +1,6 @@
|
|
|
import ctypes
|
|
|
+import platform
|
|
|
+import subprocess
|
|
|
import sys
|
|
|
import os
|
|
|
import threading
|
|
|
@@ -14,6 +16,9 @@ from app import login_account, run_threading_order, run_daily_job, run_manual_jo
|
|
|
from litter_helper import Ui_menu # 确保这个导入路径是正确的
|
|
|
from tools.utils import save_all_proxy_ip_v3
|
|
|
|
|
|
+# 定义 Redis 安装程序路径
|
|
|
+REDIS_INSTALLER_PATH = "Redis-x64-5.0.14.1.msi" # 替换为实际的安装程序路径
|
|
|
+
|
|
|
|
|
|
class ClickableLabel(QLabel):
|
|
|
def __init__(self, parent=None, file_path=None):
|
|
|
@@ -82,7 +87,7 @@ class MainWindow(QMainWindow, Ui_menu):
|
|
|
self.stopTimePushButton.clicked.connect(on_stop_time_button_click)
|
|
|
|
|
|
# 写入文件
|
|
|
- self.writeFilePushButton.clicked.connect(on_write_file_button_click)
|
|
|
+ # self.writeFilePushButton.clicked.connect(on_write_file_button_click)
|
|
|
|
|
|
# 编辑账号
|
|
|
# 获取 QLabel 控件并替换为 ClickableLabel
|
|
|
@@ -127,6 +132,9 @@ class MainWindow(QMainWindow, Ui_menu):
|
|
|
if self.watchPushButton:
|
|
|
self.watchPushButton.clicked.connect(self.on_watch_button_click)
|
|
|
|
|
|
+ # 检查 Redis 是否安装
|
|
|
+ self.check_redis_installation()
|
|
|
+
|
|
|
def on_label_click(self, file_path):
|
|
|
if os.path.exists(file_path):
|
|
|
try:
|
|
|
@@ -230,6 +238,35 @@ class MainWindow(QMainWindow, Ui_menu):
|
|
|
except Exception as e:
|
|
|
QMessageBox.critical(self, "Error", f"无法打开文件夹: {e}")
|
|
|
|
|
|
+ # 检查 Redis 是否安装
|
|
|
+ def check_redis_installation(self):
|
|
|
+ # 检查操作系统
|
|
|
+ system = platform.system()
|
|
|
+
|
|
|
+ if system == "Windows":
|
|
|
+ # 检查 Redis 服务是否正在运行
|
|
|
+ try:
|
|
|
+ # 使用 ctypes 库检查 Redis 服务是否正在运行
|
|
|
+ service_manager = ctypes.windll.advapi32.OpenServiceA(None, b"redis-server")
|
|
|
+ if service_manager:
|
|
|
+ ctypes.windll.advapi32.CloseServiceHandle(service_manager)
|
|
|
+ print("Redis 服务已安装并正在运行")
|
|
|
+ return
|
|
|
+ except Exception as e:
|
|
|
+ print(f"Redis 服务未安装或未运行: {e}")
|
|
|
+
|
|
|
+ # 如果 Redis 服务未安装,则启动安装程序
|
|
|
+ if REDIS_INSTALLER_PATH:
|
|
|
+ try:
|
|
|
+ subprocess.run([REDIS_INSTALLER_PATH], shell=True)
|
|
|
+ print("Redis 安装程序已启动")
|
|
|
+ except Exception as e:
|
|
|
+ QMessageBox.critical(self, "Error", f"无法启动 Redis 安装程序: {e}")
|
|
|
+ else:
|
|
|
+ # 在其他操作系统上,可以使用不同的方法检查 Redis 是否安装
|
|
|
+ # 例如,可以使用 `which redis-server` 命令
|
|
|
+ print("当前操作系统不支持自动安装 Redis")
|
|
|
+
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
app = QApplication(sys.argv)
|