task_status 在退出码为 0 但日志有报错时附上 errors
取自 codex/story-test-20261003 的 66418dc (DSH) 中 tasks.py 部分及其两项测试:
AALC 每日流程单次战斗失败("未能进入战斗")后仍 exit 0, 只看 succeeded 会误判。
同一提交里的编队滑动补丁未合入: 后台模式分段移动时长 <0.01s 时 AALC 的
_mouse_move_to 步数为 0 不发移动事件, 前台每段受 pyautogui 默认 0.1s 停顿
影响单次滑动约 4.4s, 且行程比 AALC 的 Windows 标定多 60px; 另行重写后实测。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,22 @@ def tail(path, n):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
ERROR_MARKERS = ('[ERROR]', 'Traceback (most recent call last)')
|
||||||
|
ERROR_SCAN_LINES = 400
|
||||||
|
|
||||||
|
|
||||||
|
def log_errors(path, limit=3):
|
||||||
|
"""挑出日志尾部的报错行。
|
||||||
|
|
||||||
|
AALC 的每日流程在单次战斗失败后会继续跑完并正常退出(exit 0), 只看退出码
|
||||||
|
会把"超出最大尝试次数,未能进入战斗"这类失败当成成功, 所以状态里额外附上
|
||||||
|
日志里的报错行。
|
||||||
|
"""
|
||||||
|
hits = [line for line in tail(path, ERROR_SCAN_LINES)
|
||||||
|
if any(marker in line for marker in ERROR_MARKERS)]
|
||||||
|
return hits[-limit:]
|
||||||
|
|
||||||
|
|
||||||
class TaskRunner:
|
class TaskRunner:
|
||||||
|
|
||||||
def __init__(self, run_dir, argv_factory=default_argv, keep_logs=20, restore_argv=default_restore_argv):
|
def __init__(self, run_dir, argv_factory=default_argv, keep_logs=20, restore_argv=default_restore_argv):
|
||||||
@@ -112,6 +128,9 @@ class TaskRunner:
|
|||||||
'log': self.info['log'], 'log_tail': tail(self.info['log'], max(1, min(int(lines), 200)))}
|
'log': self.info['log'], 'log_tail': tail(self.info['log'], max(1, min(int(lines), 200)))}
|
||||||
if code is not None:
|
if code is not None:
|
||||||
r['exit_code'] = code
|
r['exit_code'] = code
|
||||||
|
errors = log_errors(self.info['log'])
|
||||||
|
if errors:
|
||||||
|
r['errors'] = errors
|
||||||
pending = self._pending_restores()
|
pending = self._pending_restores()
|
||||||
if pending:
|
if pending:
|
||||||
r['pending_restore'] = [os.path.basename(p) for p in pending]
|
r['pending_restore'] = [os.path.basename(p) for p in pending]
|
||||||
|
|||||||
Reference in New Issue
Block a user