added manifests to create a list of expected file outputs as well as a verification script.

This commit is contained in:
2026-07-08 20:33:44 -05:00
parent d02333f9f9
commit 9303bcf0b5
4 changed files with 172 additions and 10 deletions

View File

@@ -129,19 +129,48 @@ def open_send_to_file(main, app, ctrl, timeouts):
return dlg
def perform_export(dlg, ctrl, timeouts):
"""Click Select -> then OK to start the export."""
# Wait for the Select button to be ready — the dialog may still be
# populating its controls after appearing.
def read_manifest(dlg, log):
"""Read the list of selected documents from the right-side ListView."""
try:
lv = dlg.child_window(title="List1", class_name="SysListView32")
count = lv.item_count()
if count == 0:
log(" WARNING: ListView is empty after Select")
return []
items = lv.texts()
log(f" Manifest captured: {count} documents selected")
return items
except Exception as e:
log(f" WARNING: could not read manifest from ListView: {e}")
return None
def save_manifest(drawer_id, items, manifest_dir, log):
"""Save the list of expected export items to a manifest file."""
os.makedirs(manifest_dir, exist_ok=True)
path = os.path.join(manifest_dir, f"{drawer_id}.txt")
with open(path, "w", encoding="utf-8") as f:
for row in items:
if isinstance(row, (list, tuple)):
f.write("\t".join(str(c) for c in row) + "\n")
else:
f.write(str(row) + "\n")
log(f" Manifest saved: {path}")
def perform_export(dlg, ctrl, timeouts, log):
"""Click Select -> then OK to start the export. Returns manifest list."""
select_btn = dlg.child_window(title=ctrl["select_btn_title"], class_name="Button")
select_btn.wait("visible ready enabled", timeout=timeouts["dialog"])
select_btn.click()
# 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["select"])
manifest = read_manifest(dlg, log)
ok_btn.click()
return manifest
def dismiss_any_dialog(app, ctrl, log):
@@ -228,7 +257,8 @@ def wait_for_export(app, ctrl, timeouts, log):
return True
def export_drawer(app, main, drawer_id, ctrl, timeouts, screenshot_dir, log):
def export_drawer(app, main, drawer_id, ctrl, timeouts, screenshot_dir,
manifest_dir, log):
"""Full per-drawer sequence. Returns True on success."""
log(f"Drawer {drawer_id}: starting")
@@ -248,9 +278,11 @@ def export_drawer(app, main, drawer_id, ctrl, timeouts, screenshot_dir, log):
take_screenshot(main, drawer_id, "dialog_fail", screenshot_dir, log)
return False
# 3 & 4. Select -> and OK
# 3 & 4. Select -> and OK (captures manifest before clicking OK)
try:
perform_export(dlg, ctrl, timeouts)
manifest = perform_export(dlg, ctrl, timeouts, log)
if manifest is not None:
save_manifest(drawer_id, manifest, manifest_dir, log)
except Exception as e:
log(f" ERROR during export selection: {e}")
take_screenshot(dlg, drawer_id, "export_fail", screenshot_dir, log)
@@ -284,6 +316,7 @@ def main():
"drawer_id_file": cfg.get("paths", "drawer_id_file"),
"completed_file": cfg.get("paths", "completed_file"),
"screenshot_dir": cfg.get("paths", "screenshot_dir"),
"manifest_dir": cfg.get("paths", "manifest_dir"),
}
timeouts = {
"nav": cfg.getfloat("timeouts", "nav_timeout"),
@@ -339,7 +372,8 @@ def main():
log(f"--- [{i}/{len(pending)}] Drawer {drawer_id} ---")
try:
ok = export_drawer(app, main_win, drawer_id, ctrl, timeouts,
paths["screenshot_dir"], log)
paths["screenshot_dir"],
paths["manifest_dir"], log)
except Exception as e:
log(f" UNEXPECTED ERROR on drawer {drawer_id}: {e}")
try: