h
This commit is contained in:
@@ -19,7 +19,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Set
|
||||
from dataclasses import dataclass, field
|
||||
from SYS import models
|
||||
from SYS import pipeline as pipeline_context
|
||||
from SYS.result_table import ResultTable
|
||||
from SYS.result_table import Table
|
||||
from SYS.rich_display import stderr_console as get_stderr_console
|
||||
from rich.prompt import Confirm
|
||||
from contextlib import AbstractContextManager, nullcontext
|
||||
@@ -1722,28 +1722,34 @@ def _print_live_safe_stderr(message: str) -> None:
|
||||
except Exception:
|
||||
return
|
||||
|
||||
cm = None
|
||||
cm: AbstractContextManager[Any] | None = None
|
||||
try:
|
||||
from SYS import pipeline as _pipeline_ctx # type: ignore
|
||||
|
||||
suspend = getattr(_pipeline_ctx, "suspend_live_progress", None)
|
||||
cm = suspend() if callable(suspend) else None
|
||||
candidate = suspend() if callable(suspend) else None
|
||||
if isinstance(candidate, AbstractContextManager):
|
||||
cm = candidate
|
||||
elif candidate is not None and hasattr(candidate, "__enter__") and hasattr(candidate, "__exit__"):
|
||||
cm = candidate # type: ignore[arg-type]
|
||||
except Exception:
|
||||
cm = None
|
||||
|
||||
try:
|
||||
from contextlib import nullcontext
|
||||
except Exception:
|
||||
nullcontext = None # type: ignore
|
||||
if cm is None:
|
||||
cm = nullcontext() if callable(nullcontext) else None
|
||||
cm = nullcontext()
|
||||
|
||||
try:
|
||||
if cm is not None:
|
||||
with cm:
|
||||
stderr_console.print(str(message))
|
||||
else:
|
||||
stderr_console.print(str(message))
|
||||
console = stderr_console()
|
||||
print_func = getattr(console, "print", None)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
if not callable(print_func):
|
||||
return
|
||||
|
||||
try:
|
||||
with cm:
|
||||
print_func(str(message))
|
||||
except Exception:
|
||||
return
|
||||
|
||||
@@ -1919,21 +1925,21 @@ def _print_saved_output_panel(item: Any, final_path: Path) -> None:
|
||||
|
||||
# If Rich Live progress is active, pause it while printing so the panel
|
||||
# doesn't get overwritten/truncated by Live's cursor control.
|
||||
cm: AbstractContextManager[Any] | None = None
|
||||
try:
|
||||
from SYS import pipeline as _pipeline_ctx # type: ignore
|
||||
|
||||
suspend = getattr(_pipeline_ctx, "suspend_live_progress", None)
|
||||
cm = suspend() if callable(suspend) else None
|
||||
cm_candidate = suspend() if callable(suspend) else None
|
||||
if isinstance(cm_candidate, AbstractContextManager):
|
||||
cm = cm_candidate
|
||||
elif cm_candidate is not None and hasattr(cm_candidate, "__enter__") and hasattr(cm_candidate, "__exit__"):
|
||||
cm = cm_candidate # type: ignore[arg-type]
|
||||
except Exception:
|
||||
cm = None
|
||||
|
||||
try:
|
||||
from contextlib import nullcontext
|
||||
except Exception:
|
||||
nullcontext = None # type: ignore
|
||||
|
||||
if cm is None:
|
||||
cm = nullcontext() if callable(nullcontext) else None
|
||||
cm = nullcontext()
|
||||
|
||||
try:
|
||||
location = str(final_path)
|
||||
@@ -1974,11 +1980,17 @@ def _print_saved_output_panel(item: Any, final_path: Path) -> None:
|
||||
grid.add_row("Hash", file_hash or "(unknown)")
|
||||
|
||||
try:
|
||||
if cm is not None:
|
||||
with cm:
|
||||
stderr_console.print(Panel(grid, title="Saved", expand=False))
|
||||
else:
|
||||
stderr_console.print(Panel(grid, title="Saved", expand=False))
|
||||
console = stderr_console()
|
||||
print_func = getattr(console, "print", None)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
if not callable(print_func):
|
||||
return
|
||||
|
||||
try:
|
||||
with cm:
|
||||
print_func(Panel(grid, title="Saved", expand=False))
|
||||
except Exception:
|
||||
return
|
||||
|
||||
@@ -2635,7 +2647,7 @@ def propagate_metadata(
|
||||
if p_obj.hash and p_obj.hash != "unknown":
|
||||
prev_by_hash[p_obj.hash] = p_obj
|
||||
|
||||
normalized: List[models.PipeObject] = []
|
||||
normalized: List[Any] = []
|
||||
|
||||
# Pre-calculate length matching for heuristic
|
||||
is_same_length = len(new_items) == len(prev_normalized)
|
||||
@@ -3688,11 +3700,12 @@ def check_url_exists_in_storage(
|
||||
if isinstance(response, dict):
|
||||
raw_hashes = response.get("hashes") or response.get("file_hashes")
|
||||
raw_ids = response.get("file_ids")
|
||||
hash_list = raw_hashes if isinstance(raw_hashes, list) else []
|
||||
has_ids = isinstance(raw_ids, list) and len(raw_ids) > 0
|
||||
has_hashes = isinstance(raw_hashes, list) and len(raw_hashes) > 0
|
||||
has_hashes = len(hash_list) > 0
|
||||
if has_hashes:
|
||||
try:
|
||||
found_hash = str(raw_hashes[0]).strip()
|
||||
found_hash = str(hash_list[0]).strip()
|
||||
except Exception:
|
||||
found_hash = None
|
||||
if has_ids or has_hashes:
|
||||
@@ -3816,10 +3829,10 @@ def check_url_exists_in_storage(
|
||||
_mark_preflight_checked()
|
||||
return True
|
||||
|
||||
table = ResultTable(f"URL already exists ({len(matched_urls)} url(s))", max_columns=10)
|
||||
table.set_no_choice(True)
|
||||
table = Table(f"URL already exists ({len(matched_urls)} url(s))", max_columns=10)
|
||||
table._interactive(True)
|
||||
try:
|
||||
table.set_preserve_order(True)
|
||||
table._perseverance(True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user