From 65947638cb453a87bb0268797ea3206fc7d58ae1 Mon Sep 17 00:00:00 2001 From: dat972 Date: Mon, 6 Jul 2026 23:29:41 -0500 Subject: [PATCH] updated the export code to handle failures of clicking ok after export --- config.ini | 2 +- fccs_export.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/config.ini b/config.ini index 27d47bb..3d5d204 100644 --- a/config.ini +++ b/config.ini @@ -15,7 +15,7 @@ dialog_timeout = 15 progress_appear = 30 progress_finish = 1800 settle = 1.0 -confirm_timeout = 30 +confirm_timeout = 60 [controls] main_class = CSIFCAB diff --git a/fccs_export.py b/fccs_export.py index a79f864..92b5096 100755 --- a/fccs_export.py +++ b/fccs_export.py @@ -144,6 +144,30 @@ def perform_export(dlg, ctrl, timeouts): 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: + for w in app.windows(): + if w.class_name() == "#32770" and w.is_visible(): + try: + w.child_window(title="OK", class_name="Button").click() + log(f" Dismissed stale dialog: {w.window_text()!r}") + time.sleep(0.5) + except Exception: + pass + except Exception: + pass + + def wait_for_export(app, ctrl, timeouts, log): """ Wait for the full export lifecycle to complete: @@ -167,14 +191,37 @@ def wait_for_export(app, ctrl, timeouts, log): log(f" ERROR: export did not finish within {timeouts['progress_finish']}s.") return False + # Look for the confirmation dialog — try multiple times with short waits + # since there can be a delay between progress closing and confirmation appearing. saved = app.window(title=ctrl["saved_title"], class_name=ctrl["saved_class"]) try: saved.wait("visible ready", timeout=timeouts["confirm"]) log(" Confirmation dialog appeared - export succeeded.") except timings.TimeoutError: - log(" ERROR: confirmation dialog never appeared. Export may have " - "failed or produced no output.") - return False + # Fallback: look for any #32770 dialog that appeared (title may differ) + log(" WARNING: expected confirmation dialog not found by title. " + "Checking for any popup dialog...") + found = False + try: + for w in app.windows(): + if w.class_name() == "#32770" and w.is_visible(): + log(f" Found dialog: {w.window_text()!r}") + try: + w.child_window(title="OK", class_name="Button").click() + w.wait_not("visible", timeout=10) + log(" Dismissed via fallback.") + found = True + break + except Exception: + pass + except Exception: + pass + if not found: + log(" ERROR: confirmation dialog never appeared. Export may have " + "failed or produced no output.") + return False + log(" Export complete.") + return True try: saved.child_window(title=ctrl["saved_ok_title"], class_name="Button").click() @@ -192,6 +239,9 @@ def export_drawer(app, main, drawer_id, ctrl, timeouts, screenshot_dir, log): """Full per-drawer sequence. Returns True on success.""" log(f"Drawer {drawer_id}: starting") + # 0. Dismiss any stale dialogs left from a previous failure + dismiss_any_dialog(app, ctrl, log) + # 1. Navigate if not navigate_to_drawer(main, drawer_id, ctrl, timeouts, log): take_screenshot(main, drawer_id, "nav_fail", screenshot_dir, log)