updated timeout handling and also closing stale dialog

This commit is contained in:
2026-07-07 07:36:19 -05:00
parent 574a405ec9
commit 5d6aac2fc4
2 changed files with 19 additions and 14 deletions

View File

@@ -15,6 +15,7 @@ dialog_timeout = 15
progress_appear = 30
progress_finish = 1800
settle = 1.0
select_timeout = 180
confirm_timeout = 60
[controls]

View File

@@ -140,30 +140,33 @@ def perform_export(dlg, ctrl, timeouts):
# Wait for the OK button to become ready — transferring files to the
# selected side can take a while on large drawers.
ok_btn = dlg.child_window(title=ctrl["ok_btn_title"], class_name="Button")
ok_btn.wait("visible ready enabled", timeout=timeouts["dialog"])
ok_btn.wait("visible ready enabled", timeout=timeouts["select"])
ok_btn.click()
def dismiss_any_dialog(app, ctrl, log):
"""Try to find and dismiss any stale confirmation or error dialog."""
try:
saved = app.window(title=ctrl["saved_title"], class_name=ctrl["saved_class"])
if saved.exists(timeout=1):
saved.child_window(title=ctrl["saved_ok_title"], class_name="Button").click()
log(" Dismissed stale confirmation dialog.")
time.sleep(0.5)
except Exception:
pass
# Also try to dismiss any generic #32770 dialog with an OK button
"""Try to find and dismiss any stale dialogs left from a previous failure."""
try:
for w in app.windows():
if w.class_name() == "#32770" and w.is_visible():
if not (w.class_name() == "#32770" and w.is_visible()):
continue
title = w.window_text()
# Dismiss the Send To File dialog (Cancel)
if title == ctrl["dialog_title"]:
try:
w.child_window(title="OK", class_name="Button").click()
log(f" Dismissed stale dialog: {w.window_text()!r}")
w.child_window(title="Cancel", class_name="Button").click()
log(f" Dismissed stale Send To File dialog.")
time.sleep(0.5)
except Exception:
pass
continue
# Dismiss any other dialog (OK)
try:
w.child_window(title="OK", class_name="Button").click()
log(f" Dismissed stale dialog: {title!r}")
time.sleep(0.5)
except Exception:
pass
except Exception:
pass
@@ -300,6 +303,7 @@ def main():
timeouts = {
"nav": cfg.getfloat("timeouts", "nav_timeout"),
"dialog": cfg.getfloat("timeouts", "dialog_timeout"),
"select": cfg.getfloat("timeouts", "select_timeout"),
"progress_appear": cfg.getfloat("timeouts", "progress_appear"),
"progress_finish": cfg.getfloat("timeouts", "progress_finish"),
"settle": cfg.getfloat("timeouts", "settle"),