ASCII-compatible status display.
| 126 | |
| 127 | |
| 128 | class ASCIIStatusDisplay(ProcessStatusDisplay): |
| 129 | """ASCII-compatible status display.""" |
| 130 | |
| 131 | def __init__( |
| 132 | self, group: "RunningProcessGroup", config: Optional[DisplayConfig] = None |
| 133 | ): |
| 134 | if config is None: |
| 135 | config = DisplayConfig(format_type="ascii") |
| 136 | super().__init__(group, config) |
| 137 | |
| 138 | self._spinner_chars = ["|", "/", "-", "\\\\"] |
| 139 | self._status_chars = { |
| 140 | "running": "|>", |
| 141 | "done": "OK", |
| 142 | "failed": "XX", |
| 143 | "pending": "--", |
| 144 | } |
| 145 | |
| 146 | def format_status_line( |
| 147 | self, group_status: "GroupStatus", spinner_index: int |
| 148 | ) -> str: |
| 149 | """Format status display using ASCII characters.""" |
| 150 | lines: list[str] = [] |
| 151 | |
| 152 | # Header |
| 153 | lines.append( |
| 154 | f"Process Group: {group_status.group_name} - Progress: {group_status.completed_processes}/{group_status.total_processes} ({group_status.completion_percentage:.1f}%)" |
| 155 | ) |
| 156 | lines.append("-" * 80) |
| 157 | |
| 158 | # Process status lines |
| 159 | for proc_status in group_status.processes: |
| 160 | # Get status character |
| 161 | if proc_status.is_alive: |
| 162 | status_char = self._spinner_chars[ |
| 163 | spinner_index % len(self._spinner_chars) |
| 164 | ] |
| 165 | elif proc_status.is_completed: |
| 166 | if proc_status.return_value == 0: |
| 167 | status_char = self._status_chars["done"] |
| 168 | else: |
| 169 | status_char = self._status_chars["failed"] |
| 170 | else: |
| 171 | status_char = self._status_chars["pending"] |
| 172 | |
| 173 | # Format fields |
| 174 | name = proc_status.name[: self.config.max_name_width].ljust( |
| 175 | self.config.max_name_width |
| 176 | ) |
| 177 | |
| 178 | if proc_status.is_completed: |
| 179 | status_text = f"DONE({proc_status.return_value or 0})" |
| 180 | elif proc_status.is_alive: |
| 181 | status_text = "RUNNING" |
| 182 | else: |
| 183 | status_text = "PENDING" |
| 184 | |
| 185 | duration = f"{proc_status.running_time_seconds:.1f}s" |
no outgoing calls
no test coverage detected