This commit is contained in:
2026-01-31 19:00:04 -08:00
parent dcf16e0cc4
commit 6513a3ad04
25 changed files with 617 additions and 397 deletions

View File

@@ -43,6 +43,9 @@ else:
# Reuse the existing format_bytes helper under a clearer alias
from SYS.utils import format_bytes as format_mb
import logging
logger = logging.getLogger(__name__)
def _sanitize_cell_text(value: Any) -> str:
"""Coerce to a single-line, tab-free string suitable for terminal display."""
@@ -82,6 +85,7 @@ def _format_duration_hms(duration: Any) -> str:
else:
seconds = float(duration)
except Exception:
logger.debug("Failed to format duration '%s' to hms", duration, exc_info=True)
return ""
if seconds < 0:
@@ -118,6 +122,7 @@ class TableColumn:
try:
return self.extractor(item)
except Exception:
logger.exception("TableColumn.extract failed for key '%s'", self.key)
return None
@@ -137,6 +142,7 @@ def _as_dict(item: Any) -> Optional[Dict[str, Any]]:
if hasattr(item, "__dict__"):
return dict(getattr(item, "__dict__"))
except Exception:
logger.exception("Failed to convert %s to dict in _as_dict", type(item))
return None
return None
@@ -201,6 +207,7 @@ def extract_ext_value(item: Any) -> str:
if suf:
ext = suf.lstrip(".")
except Exception:
logger.debug("Failed to extract suffix from raw_path: %r", raw_path, exc_info=True)
ext = ""
ext_str = str(ext or "").strip().lstrip(".")
@@ -242,6 +249,7 @@ def extract_size_bytes_value(item: Any) -> Optional[int]:
# Some sources might provide floats or numeric strings
return int(float(s))
except Exception:
logger.debug("Failed to parse size value '%r' to int", size_val, exc_info=True)
return None
@@ -471,6 +479,7 @@ class Table:
"get_current_cmdlet_name") else ""
)
except Exception:
logger.debug("Failed to get current cmdlet name from pipeline context", exc_info=True)
cmdlet_name = ""
stage_text = ""
@@ -481,6 +490,7 @@ class Table:
"get_current_stage_text") else ""
)
except Exception:
logger.debug("Failed to get current stage text from pipeline context", exc_info=True)
stage_text = ""
if cmdlet_name and stage_text:
@@ -494,7 +504,8 @@ class Table:
"-").startswith(normalized_cmd):
self.title = normalized_stage
except Exception:
pass
from SYS.logger import logger
logger.exception("Failed to introspect pipeline context to set ResultTable title")
self.title_width = title_width
self.max_columns = (
max_columns if max_columns is not None else 5
@@ -558,6 +569,7 @@ class Table:
try:
return dict(self.table_metadata)
except Exception:
logger.exception("Failed to copy table metadata")
return {}
def _interactive(self, interactive: bool = True) -> "Table":
@@ -835,7 +847,8 @@ class Table:
val = col.format_fn(val)
row.add_column(col.header, val)
except Exception:
pass
from SYS.logger import logger
logger.exception("Failed to extract column '%s' for row %r", getattr(col, 'header', '<col>'), r)
return instance
@@ -913,11 +926,13 @@ class Table:
md = getattr(result, "full_metadata", None)
md_dict = dict(md) if isinstance(md, dict) else {}
except Exception:
logger.debug("Failed to extract full_metadata for result of type %s", type(result), exc_info=True)
md_dict = {}
try:
selection_args = getattr(result, "selection_args", None)
except Exception:
logger.debug("Failed to get selection_args from result of type %s", type(result), exc_info=True)
selection_args = None
if selection_args is None:
selection_args = md_dict.get("_selection_args") or md_dict.get("selection_args")
@@ -927,6 +942,7 @@ class Table:
try:
selection_action = getattr(result, "selection_action", None)
except Exception:
logger.debug("Failed to get selection_action from result of type %s", type(result), exc_info=True)
selection_action = None
if selection_action is None:
selection_action = md_dict.get("_selection_action") or md_dict.get("selection_action")
@@ -1084,13 +1100,16 @@ class Table:
and "table" not in visible_data and "source" not in visible_data):
visible_data["store"] = store_extracted
except Exception:
pass
from SYS.logger import logger
logger.exception("Failed to extract store value for item: %r", data)
try:
ext_extracted = extract_ext_value(data)
# Always ensure `ext` exists so priority_groups keeps a stable column.
visible_data["ext"] = str(ext_extracted or "")
except Exception:
from SYS.logger import logger
logger.exception("Failed to extract ext value for item: %r", data)
visible_data.setdefault("ext", "")
try:
@@ -1099,7 +1118,8 @@ class Table:
and "size" not in visible_data):
visible_data["size_bytes"] = size_extracted
except Exception:
pass
from SYS.logger import logger
logger.exception("Failed to extract size bytes for item: %r", data)
# Handle extension separation for local files
store_val = str(
@@ -1168,7 +1188,8 @@ class Table:
col_value,
integer_only=False
)
except Exception:
except Exception as exc:
logger.debug("Failed to format 'size' column value: %r", col_value, exc_info=True)
col_value_str = format_value(col_value)
elif isinstance(col_name,
str) and col_name.strip().lower() == "duration":
@@ -1178,7 +1199,8 @@ class Table:
else:
dur = _format_duration_hms(col_value)
col_value_str = dur or format_value(col_value)
except Exception:
except Exception as exc:
logger.debug("Failed to format 'duration' column value: %r", col_value, exc_info=True)
col_value_str = format_value(col_value)
else:
col_value_str = format_value(col_value)
@@ -1201,7 +1223,7 @@ class Table:
) # Don't display full metadata as column
except Exception:
# Fall back to regular field handling if columns format is unexpected
pass
logger.exception("Failed to process 'columns' dynamic field list: %r", visible_data.get("columns"))
# Only add priority groups if we haven't already filled columns from 'columns' field
if column_count == 0: