修复#9与人工排查模式报错
This commit is contained in:
101
AUTO_MAA.py
101
AUTO_MAA.py
@@ -27,6 +27,7 @@ v4.1
|
|||||||
|
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QWidget,
|
QWidget,
|
||||||
|
QMainWindow,
|
||||||
QApplication,
|
QApplication,
|
||||||
QInputDialog,
|
QInputDialog,
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
@@ -83,7 +84,6 @@ class MaaRunner(QtCore.QThread):
|
|||||||
app_path = os.path.dirname(os.path.realpath(sys.argv[0])).replace(
|
app_path = os.path.dirname(os.path.realpath(sys.argv[0])).replace(
|
||||||
"\\", "/"
|
"\\", "/"
|
||||||
) # 获取软件自身的路径
|
) # 获取软件自身的路径
|
||||||
if_run = False
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, set_path, log_path, maa_path, routine, annihilation, num, data, mode
|
self, set_path, log_path, maa_path, routine, annihilation, num, data, mode
|
||||||
@@ -102,7 +102,6 @@ class MaaRunner(QtCore.QThread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""主进程,运行MAA代理进程"""
|
"""主进程,运行MAA代理进程"""
|
||||||
self.if_run = True
|
|
||||||
curdate = server_date()
|
curdate = server_date()
|
||||||
begin_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
begin_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
self.data = sorted(self.data, key=lambda x: (-len(x[15]), x[16]))
|
self.data = sorted(self.data, key=lambda x: (-len(x[15]), x[16]))
|
||||||
@@ -124,18 +123,18 @@ class MaaRunner(QtCore.QThread):
|
|||||||
self.data[_][0] += "_第" + str(self.data[_][14] + 1) + "次代理"
|
self.data[_][0] += "_第" + str(self.data[_][14] + 1) + "次代理"
|
||||||
# 开始代理
|
# 开始代理
|
||||||
for index in all_index:
|
for index in all_index:
|
||||||
if not self.if_run:
|
if self.isInterruptionRequested():
|
||||||
break
|
break
|
||||||
# 初始化代理情况记录和模式替换记录
|
# 初始化代理情况记录和模式替换记录
|
||||||
run_book = [False for _ in range(2)]
|
run_book = [False for _ in range(2)]
|
||||||
mode_book = ["日常代理_剿灭", "日常代理_日常"]
|
mode_book = ["日常代理_剿灭", "日常代理_日常"]
|
||||||
# 尝试次数循环
|
# 尝试次数循环
|
||||||
for i in range(self.num):
|
for i in range(self.num):
|
||||||
if not self.if_run:
|
if self.isInterruptionRequested():
|
||||||
break
|
break
|
||||||
# 剿灭-日常模式循环
|
# 剿灭-日常模式循环
|
||||||
for j in range(2):
|
for j in range(2):
|
||||||
if not self.if_run:
|
if self.isInterruptionRequested():
|
||||||
break
|
break
|
||||||
if j == 0 and self.data[index][10] == "n":
|
if j == 0 and self.data[index][10] == "n":
|
||||||
run_book[0] = True
|
run_book[0] = True
|
||||||
@@ -157,7 +156,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
if (not _ in over_index + error_index + [index])
|
if (not _ in over_index + error_index + [index])
|
||||||
]
|
]
|
||||||
# 监测MAA运行状态
|
# 监测MAA运行状态
|
||||||
while self.if_run:
|
while not self.isInterruptionRequested():
|
||||||
# 获取MAA日志
|
# 获取MAA日志
|
||||||
logs = self.get_maa_log(start_time)
|
logs = self.get_maa_log(start_time)
|
||||||
# 判断是否超时
|
# 判断是否超时
|
||||||
@@ -262,7 +261,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
+ "出现异常",
|
+ "出现异常",
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
if self.if_run:
|
if not self.isInterruptionRequested():
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
break
|
break
|
||||||
if run_book[0] and run_book[1]:
|
if run_book[0] and run_book[1]:
|
||||||
@@ -290,13 +289,13 @@ class MaaRunner(QtCore.QThread):
|
|||||||
self.data[_][0] += "_排查模式"
|
self.data[_][0] += "_排查模式"
|
||||||
# 开始排查
|
# 开始排查
|
||||||
for index in all_index:
|
for index in all_index:
|
||||||
if not self.if_run:
|
if self.isInterruptionRequested():
|
||||||
break
|
break
|
||||||
if self.data[index][15] == "beta":
|
if self.data[index][15] == "beta":
|
||||||
if_strat_app = True
|
if_strat_app = True
|
||||||
run_book = [False for _ in range(2)]
|
run_book = [False for _ in range(2)]
|
||||||
# 启动重试循环
|
# 启动重试循环
|
||||||
while self.if_run:
|
while not self.isInterruptionRequested():
|
||||||
# 配置MAA
|
# 配置MAA
|
||||||
if if_strat_app:
|
if if_strat_app:
|
||||||
self.set_maa("人工排查_启动模拟器", index)
|
self.set_maa("人工排查_启动模拟器", index)
|
||||||
@@ -314,7 +313,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
if (not _ in over_index + error_index + [index])
|
if (not _ in over_index + error_index + [index])
|
||||||
]
|
]
|
||||||
# 监测MAA运行状态
|
# 监测MAA运行状态
|
||||||
while self.if_run:
|
while not self.isInterruptionRequested():
|
||||||
# 获取MAA日志
|
# 获取MAA日志
|
||||||
logs = self.get_maa_log(start_time)
|
logs = self.get_maa_log(start_time)
|
||||||
# 合并日志
|
# 合并日志
|
||||||
@@ -322,11 +321,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
# 更新MAA日志
|
# 更新MAA日志
|
||||||
if len(logs) > 100:
|
if len(logs) > 100:
|
||||||
self.update_gui.emit(
|
self.update_gui.emit(
|
||||||
self.data[index][0]
|
self.data[index][0],
|
||||||
+ "_第"
|
|
||||||
+ str(i + 1)
|
|
||||||
+ "次_"
|
|
||||||
+ mode_book[j][5:7],
|
|
||||||
"\n".join([self.data[_][0] for _ in wait_index]),
|
"\n".join([self.data[_][0] for _ in wait_index]),
|
||||||
"\n".join([self.data[_][0] for _ in over_index]),
|
"\n".join([self.data[_][0] for _ in over_index]),
|
||||||
"\n".join([self.data[_][0] for _ in error_index]),
|
"\n".join([self.data[_][0] for _ in error_index]),
|
||||||
@@ -334,11 +329,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.update_gui.emit(
|
self.update_gui.emit(
|
||||||
self.data[index][0]
|
self.data[index][0],
|
||||||
+ "_第"
|
|
||||||
+ str(i + 1)
|
|
||||||
+ "次_"
|
|
||||||
+ mode_book[j][5:7],
|
|
||||||
"\n".join([self.data[_][0] for _ in wait_index]),
|
"\n".join([self.data[_][0] for _ in wait_index]),
|
||||||
"\n".join([self.data[_][0] for _ in over_index]),
|
"\n".join([self.data[_][0] for _ in over_index]),
|
||||||
"\n".join([self.data[_][0] for _ in error_index]),
|
"\n".join([self.data[_][0] for _ in error_index]),
|
||||||
@@ -374,12 +365,12 @@ class MaaRunner(QtCore.QThread):
|
|||||||
)
|
)
|
||||||
killprocess.wait()
|
killprocess.wait()
|
||||||
if_strat_app = True
|
if_strat_app = True
|
||||||
if self.if_run:
|
if not self.isInterruptionRequested():
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
break
|
break
|
||||||
if run_book[0]:
|
if run_book[0]:
|
||||||
break
|
break
|
||||||
elif self.if_run:
|
elif not self.isInterruptionRequested():
|
||||||
self.question_title = "操作提示"
|
self.question_title = "操作提示"
|
||||||
self.question_info = "MAA未能正确登录到PRTS,是否重试?"
|
self.question_info = "MAA未能正确登录到PRTS,是否重试?"
|
||||||
self.question_choice = "wait"
|
self.question_choice = "wait"
|
||||||
@@ -388,7 +379,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if self.question_choice == "No":
|
if self.question_choice == "No":
|
||||||
break
|
break
|
||||||
if run_book[0] and self.if_run:
|
if run_book[0] and not self.isInterruptionRequested():
|
||||||
self.question_title = "操作提示"
|
self.question_title = "操作提示"
|
||||||
self.question_info = "请检查用户代理情况,如无异常请按下确认键。"
|
self.question_info = "请检查用户代理情况,如无异常请按下确认键。"
|
||||||
self.question_choice = "wait"
|
self.question_choice = "wait"
|
||||||
@@ -416,7 +407,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
# 记录当前时间
|
# 记录当前时间
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
# 监测MAA运行状态
|
# 监测MAA运行状态
|
||||||
while self.if_run:
|
while not self.isInterruptionRequested():
|
||||||
# 获取MAA日志
|
# 获取MAA日志
|
||||||
logs = self.get_maa_log(start_time)
|
logs = self.get_maa_log(start_time)
|
||||||
# 合并日志
|
# 合并日志
|
||||||
@@ -433,10 +424,9 @@ class MaaRunner(QtCore.QThread):
|
|||||||
elif "用户" in self.mode:
|
elif "用户" in self.mode:
|
||||||
self.get_json.emit(self.get_json_path)
|
self.get_json.emit(self.get_json_path)
|
||||||
self.accomplish.emit()
|
self.accomplish.emit()
|
||||||
self.if_run = False
|
|
||||||
if self.mode in ["日常代理", "人工排查"]:
|
if self.mode in ["日常代理", "人工排查"]:
|
||||||
# 关闭可能未正常退出的MAA进程
|
# 关闭可能未正常退出的MAA进程
|
||||||
if not self.if_run:
|
if self.isInterruptionRequested():
|
||||||
killprocess = subprocess.Popen(
|
killprocess = subprocess.Popen(
|
||||||
"taskkill /F /T /PID " + str(maa.pid),
|
"taskkill /F /T /PID " + str(maa.pid),
|
||||||
shell=True,
|
shell=True,
|
||||||
@@ -490,7 +480,6 @@ class MaaRunner(QtCore.QThread):
|
|||||||
10,
|
10,
|
||||||
)
|
)
|
||||||
self.accomplish.emit()
|
self.accomplish.emit()
|
||||||
self.if_run = False
|
|
||||||
|
|
||||||
def get_maa_log(self, start_time):
|
def get_maa_log(self, start_time):
|
||||||
"""获取MAA日志"""
|
"""获取MAA日志"""
|
||||||
@@ -529,7 +518,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
return "检测到MAA进程异常\n正在中止相关程序\n请等待10s"
|
return "检测到MAA进程异常\n正在中止相关程序\n请等待10s"
|
||||||
elif self.if_time_out:
|
elif self.if_time_out:
|
||||||
return "检测到MAA进程超时\n正在中止相关程序\n请等待10s"
|
return "检测到MAA进程超时\n正在中止相关程序\n请等待10s"
|
||||||
elif not self.if_run:
|
elif self.isInterruptionRequested():
|
||||||
return "您中止了本次任务\n正在中止相关程序\n请等待"
|
return "您中止了本次任务\n正在中止相关程序\n请等待"
|
||||||
else:
|
else:
|
||||||
return "Wait"
|
return "Wait"
|
||||||
@@ -542,7 +531,7 @@ class MaaRunner(QtCore.QThread):
|
|||||||
or ("MaaAssistantArknights GUI exited" in log)
|
or ("MaaAssistantArknights GUI exited" in log)
|
||||||
):
|
):
|
||||||
return "检测到MAA进程异常\n正在中止相关程序\n请等待10s"
|
return "检测到MAA进程异常\n正在中止相关程序\n请等待10s"
|
||||||
elif not self.if_run:
|
elif self.isInterruptionRequested():
|
||||||
return "您中止了本次任务\n正在中止相关程序\n请等待"
|
return "您中止了本次任务\n正在中止相关程序\n请等待"
|
||||||
else:
|
else:
|
||||||
return "Wait"
|
return "Wait"
|
||||||
@@ -968,7 +957,7 @@ class MainTimer(QtCore.QThread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""主功能代码,实现定时执行以及相关配置信息的实时同步"""
|
"""主功能代码,实现定时执行以及相关配置信息的实时同步"""
|
||||||
while True:
|
while not self.isInterruptionRequested():
|
||||||
self.get_config.emit()
|
self.get_config.emit()
|
||||||
self.set_system()
|
self.set_system()
|
||||||
time_set = [
|
time_set = [
|
||||||
@@ -1114,7 +1103,6 @@ class Main(QWidget):
|
|||||||
]
|
]
|
||||||
|
|
||||||
self.ui = uiLoader.load(self.app_path + "/gui/ui/main.ui")
|
self.ui = uiLoader.load(self.app_path + "/gui/ui/main.ui")
|
||||||
self.ui.setWindowIcon(QIcon(self.app_path + "/gui/ico/AUTO_MAA.ico"))
|
|
||||||
# 检查文件完整性
|
# 检查文件完整性
|
||||||
self.initialize()
|
self.initialize()
|
||||||
self.check_config()
|
self.check_config()
|
||||||
@@ -1199,6 +1187,9 @@ class Main(QWidget):
|
|||||||
self.check_update = self.ui.findChild(QPushButton, "pushButton_check_update")
|
self.check_update = self.ui.findChild(QPushButton, "pushButton_check_update")
|
||||||
self.check_update.clicked.connect(self.check_version)
|
self.check_update.clicked.connect(self.check_version)
|
||||||
|
|
||||||
|
self.tips = self.ui.findChild(QTextBrowser, "textBrowser_tips")
|
||||||
|
self.tips.setOpenExternalLinks(True)
|
||||||
|
|
||||||
self.run_text = self.ui.findChild(QTextBrowser, "textBrowser_run")
|
self.run_text = self.ui.findChild(QTextBrowser, "textBrowser_run")
|
||||||
self.wait_text = self.ui.findChild(QTextBrowser, "textBrowser_wait")
|
self.wait_text = self.ui.findChild(QTextBrowser, "textBrowser_wait")
|
||||||
self.over_text = self.ui.findChild(QTextBrowser, "textBrowser_over")
|
self.over_text = self.ui.findChild(QTextBrowser, "textBrowser_over")
|
||||||
@@ -2321,13 +2312,6 @@ class Main(QWidget):
|
|||||||
self.MainTimer.is_maa_run = True
|
self.MainTimer.is_maa_run = True
|
||||||
self.MaaRunner.start()
|
self.MaaRunner.start()
|
||||||
|
|
||||||
def maa_ender(self, mode):
|
|
||||||
"""中止MAA线程"""
|
|
||||||
self.MaaRunner.if_run = False
|
|
||||||
self.MaaRunner.wait()
|
|
||||||
self.MainTimer.is_maa_run = False
|
|
||||||
self.maa_running_set(mode)
|
|
||||||
|
|
||||||
def maa_running_set(self, mode):
|
def maa_running_set(self, mode):
|
||||||
"""处理MAA运行过程中的GUI组件变化"""
|
"""处理MAA运行过程中的GUI组件变化"""
|
||||||
if "开始" in mode:
|
if "开始" in mode:
|
||||||
@@ -2397,6 +2381,14 @@ class Main(QWidget):
|
|||||||
self.run_now.setText("立即执行")
|
self.run_now.setText("立即执行")
|
||||||
self.run_now.clicked.connect(self.routine_starter)
|
self.run_now.clicked.connect(self.routine_starter)
|
||||||
|
|
||||||
|
def maa_ender(self, mode):
|
||||||
|
"""中止MAA线程"""
|
||||||
|
self.MainTimer.quit()
|
||||||
|
self.MaaRunner.requestInterruption()
|
||||||
|
self.MaaRunner.wait()
|
||||||
|
self.MainTimer.is_maa_run = False
|
||||||
|
self.maa_running_set(mode)
|
||||||
|
|
||||||
def check_version(self):
|
def check_version(self):
|
||||||
"""检查版本更新,调起文件下载进程"""
|
"""检查版本更新,调起文件下载进程"""
|
||||||
# 从本地版本信息文件获取当前版本信息
|
# 从本地版本信息文件获取当前版本信息
|
||||||
@@ -2486,22 +2478,27 @@ class Main(QWidget):
|
|||||||
"""同步配置文件到子线程"""
|
"""同步配置文件到子线程"""
|
||||||
self.MainTimer.config = self.config
|
self.MainTimer.config = self.config
|
||||||
|
|
||||||
def closeEvent(self, event):
|
|
||||||
"""清理残余进程"""
|
|
||||||
self.MainTimer.quit()
|
|
||||||
self.MaaRunner.if_run = False
|
|
||||||
self.MaaRunner.wait()
|
|
||||||
self.cur.close()
|
|
||||||
self.db.close()
|
|
||||||
super().closeEvent(event)
|
|
||||||
|
|
||||||
|
class AUTO_MAA(QMainWindow):
|
||||||
class AUTO_MAA(QApplication):
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.main = Main()
|
self.main = Main()
|
||||||
self.main.ui.show()
|
self.setCentralWidget(self.main.ui)
|
||||||
|
self.setWindowIcon(QIcon(self.main.app_path + "/gui/ico/AUTO_MAA.ico"))
|
||||||
|
self.setWindowTitle("AUTO_MAA")
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
"""清理残余进程"""
|
||||||
|
self.main.MainTimer.requestInterruption()
|
||||||
|
self.main.MainTimer.quit()
|
||||||
|
self.main.MainTimer.wait()
|
||||||
|
self.main.MaaRunner.requestInterruption()
|
||||||
|
self.main.MaaRunner.quit()
|
||||||
|
self.main.MaaRunner.wait()
|
||||||
|
self.main.cur.close()
|
||||||
|
self.main.db.close()
|
||||||
|
event.accept()
|
||||||
|
|
||||||
|
|
||||||
def server_date():
|
def server_date():
|
||||||
@@ -2513,5 +2510,7 @@ def server_date():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = AUTO_MAA()
|
app = QApplication(sys.argv)
|
||||||
app.exec()
|
window = AUTO_MAA()
|
||||||
|
window.show()
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|||||||
@@ -1257,7 +1257,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextBrowser" name="textBrowser">
|
<widget class="QTextBrowser" name="textBrowser_tips">
|
||||||
<property name="html">
|
<property name="html">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"main_version": "4.1.2.0",
|
"main_version": "4.1.2.1",
|
||||||
"main_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2/AUTO_MAA_v4.1.2.zip",
|
"main_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2_beta/AUTO_MAA_v4.1.2.zip",
|
||||||
"updater_version": "1.0.2.0",
|
"updater_version": "1.0.2.0",
|
||||||
"updater_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2/Updater_v1.0.2.zip",
|
"updater_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2_beta/Updater_v1.0.2.zip",
|
||||||
"announcement": "\n# 公测版,若出现问题请及时反馈给项目组!\n## 新增功能\n- 添加`启动AUTO_MAA后直接代理`功能\n- 添加无限代理天数模式\n## 修复BUG\n- 尝试解决卡日志情况\n## 程序优化\n- Updater.exe图标更换\n- 更新逻辑优化"
|
"announcement": "\n# 公测版,若出现问题请及时反馈给项目组!\n## 新增功能\n- 添加`启动AUTO_MAA后直接代理`功能\n- 添加无限代理天数模式\n## 修复BUG\n- 通过限制日志长度解决卡日志情况\n- 修复tips链接无法打开问题 #9\n- 修复正常退出窗口显示停止工作问题 #9\n## 程序优化\n- Updater.exe图标更换\n- 更新逻辑优化\n- GUI窗口逻辑优化"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user