Helper function to read logs from installers created with briefcase. The encoding can vary between the different logs.
(path: Path, last_digits: int)
| 367 | |
| 368 | |
| 369 | def _read_briefcase_log_tail(path: Path, last_digits: int) -> str: |
| 370 | """Helper function to read logs from installers created with briefcase. |
| 371 | The encoding can vary between the different logs. |
| 372 | """ |
| 373 | if not path or not path.exists(): |
| 374 | return f"(log not found: {path})" |
| 375 | |
| 376 | # Try UTF-16 first (MSI logs), fallback to UTF-8 |
| 377 | try: |
| 378 | text = path.read_text(encoding="utf-16", errors="replace") |
| 379 | except UnicodeError: |
| 380 | text = path.read_text(encoding="utf-8", errors="replace") |
| 381 | |
| 382 | return text[last_digits:] |
| 383 | |
| 384 | |
| 385 | @dataclass |