fix: preserve native calls on stop and keep status reads observational
This commit is contained in:
1 parent
97a3de20c9
commit
8d3eab1164
19 files changed
+631
-290
No files matched your search
@@ -284,9 +284,8 @@ def scan_open_library_status(library: Path, names, *, tree_image_reader=None,
|
||||
image_status_map=image_status_map)
|
||||
status = reconcile_statuses(tree_statuses, fallback, names)
|
||||
uncalibrated = [name for name in names if status.get(name, 'UNKNOWN') == 'UNKNOWN']
|
||||
# The UI must never use UNKNOWN as a skip signal. Queue it as Pending
|
||||
# so it receives the real Verify flow instead of being silently omitted.
|
||||
effective = {name: ('PENDING' if value == 'UNKNOWN' else value)
|
||||
# Missing observations remain unknown; eligibility is decided by the caller.
|
||||
effective = {name: (value if tree_images.get(name) is not None else 'UNKNOWN')
|
||||
for name, value in status.items()}
|
||||
logger.info(
|
||||
'library_status_sources names=%s image_histogram=%s current_image_map=%s cached_image_map=%s image_status_map=%s cache_actions=%s filesystem=%s calibrated_tree=%s final=%s uncalibrated_sample=%s conflicts=%s ready_anchor_ids=%s unseen_tree_ids=%s',
|
||||
@@ -328,46 +327,14 @@ def scan_open_library_status(library: Path, names, *, tree_image_reader=None,
|
||||
return effective
|
||||
|
||||
try:
|
||||
from pywinauto import Desktop
|
||||
from pywinauto.controls.common_controls import TreeViewWrapper
|
||||
from cbb_refresh_verify.mentor_adapter import _tree_image, same_path
|
||||
target = None
|
||||
for window in Desktop(backend='win32').windows():
|
||||
title = window.window_text()
|
||||
if title.startswith('Library Manager:') and same_path(title.split(':', 1)[1].strip(), library):
|
||||
target = window
|
||||
break
|
||||
if target is None:
|
||||
if tree_image_reader is None:
|
||||
from cbb_refresh_verify.mentor_adapter import read_library_tree_image_map
|
||||
tree_image_reader = read_library_tree_image_map
|
||||
return finish(tree_image_reader(library, names))
|
||||
trees = [w for w in target.descendants() if 'TreeView' in w.class_name()]
|
||||
if len(trees) != 1:
|
||||
return finish({})
|
||||
tree = TreeViewWrapper(trees[0].handle)
|
||||
root_name = Path(library).name
|
||||
images = {}
|
||||
missing = []
|
||||
for name in names:
|
||||
try:
|
||||
item = tree.get_item(['Central Libraries', root_name, 'Reusable Blocks', 'Logical-Physical', name], exact=True)
|
||||
from cbb_refresh_verify.mentor_adapter import _tree_image_details
|
||||
details = _tree_image_details(item, tree)
|
||||
images[name] = details['image_id']
|
||||
logger.info('library_tree_image_item name=%s image_id=%s selected_image_id=%s state_image_id=%s image_color=%s selected_image_color=%s state_image_color=%s',
|
||||
name, details['image_id'], details['selected_image_id'],
|
||||
details['state_image_id'], details['image_color'],
|
||||
details['selected_image_color'], details['state_image_color'])
|
||||
except Exception:
|
||||
images[name] = None
|
||||
missing.append(name)
|
||||
logger.info('library_tree_image_probe requested=%s read=%s missing=%s',
|
||||
len(names), len(names) - len(missing), missing[:20])
|
||||
return finish(images)
|
||||
if tree_image_reader is None:
|
||||
from .mentor_adapter import read_library_tree_image_map
|
||||
tree_image_reader = read_library_tree_image_map
|
||||
return finish(tree_image_reader(library, names))
|
||||
except Exception as error:
|
||||
logger.warning('library_status_probe_failed path=%s error=%s', library, error)
|
||||
return finish({})
|
||||
return {name: 'UNKNOWN' for name in names}
|
||||
|
||||
|
||||
|
||||
def read_library(path: Path, *, dispatch=None):
|
||||
|
||||
Reference in new issue
Block a user