Rich library-based status display with enhanced formatting.
| 195 | |
| 196 | |
| 197 | class RichStatusDisplay(ProcessStatusDisplay): |
| 198 | """Rich library-based status display with enhanced formatting.""" |
| 199 | |
| 200 | def __init__( |
| 201 | self, group: "RunningProcessGroup", config: Optional[DisplayConfig] = None |
| 202 | ): |
| 203 | if config is None: |
| 204 | config = DisplayConfig(format_type="rich") |
| 205 | super().__init__(group, config) |
| 206 | |
| 207 | try: |
| 208 | from rich.console import Console |
| 209 | from rich.live import Live |
| 210 | from rich.progress import Progress |
| 211 | from rich.table import Table |
| 212 | |
| 213 | self.Progress = Progress |
| 214 | self.Live = Live |
| 215 | self.Table = Table |
| 216 | self.Console = Console |
| 217 | self._rich_available = True |
| 218 | |
| 219 | self._spinner_chars = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧"] |
| 220 | self._status_chars = { |
| 221 | "running": "⠋", |
| 222 | "done": "✓", |
| 223 | "failed": "✗", |
| 224 | "pending": " ", |
| 225 | } |
| 226 | except ImportError: |
| 227 | logger.warning("Rich not available, falling back to ASCII display") |
| 228 | self._rich_available = False |
| 229 | # Fallback to ASCII chars |
| 230 | self._spinner_chars = ["|", "/", "-", "\\\\"] |
| 231 | self._status_chars = { |
| 232 | "running": "|>", |
| 233 | "done": "OK", |
| 234 | "failed": "XX", |
| 235 | "pending": "--", |
| 236 | } |
| 237 | |
| 238 | def format_status_line( |
| 239 | self, group_status: "GroupStatus", spinner_index: int |
| 240 | ) -> str: |
| 241 | """Format status display using Rich library features.""" |
| 242 | if not self._rich_available: |
| 243 | # Fallback to ASCII formatting |
| 244 | return self._format_ascii_fallback(group_status, spinner_index) |
| 245 | |
| 246 | try: |
| 247 | return self._format_rich_display(group_status, spinner_index) |
| 248 | except KeyboardInterrupt as ki: |
| 249 | handle_keyboard_interrupt(ki) |
| 250 | raise |
| 251 | except Exception as e: |
| 252 | logger.warning(f"Rich formatting failed, using ASCII fallback: {e}") |
| 253 | return self._format_ascii_fallback(group_status, spinner_index) |
| 254 |
no outgoing calls
no test coverage detected