(prompt_message: str, timeout_seconds: int = 30)
| 592 | |
| 593 | # --- Input function with timeout (from dev - more robust Windows implementation) --- |
| 594 | def input_with_timeout(prompt_message: str, timeout_seconds: int = 30) -> str: |
| 595 | print(prompt_message, end="", flush=True) |
| 596 | if sys.platform == "win32": |
| 597 | user_input_container = [None] |
| 598 | |
| 599 | def get_input_in_thread(): |
| 600 | try: |
| 601 | user_input_container[0] = sys.stdin.readline().strip() |
| 602 | except Exception: |
| 603 | user_input_container[0] = "" # Return empty string on error |
| 604 | |
| 605 | input_thread = threading.Thread(target=get_input_in_thread, daemon=True) |
| 606 | input_thread.start() |
| 607 | input_thread.join(timeout=timeout_seconds) |
| 608 | if input_thread.is_alive(): |
| 609 | print("\nInput timed out. Using default value.", flush=True) |
| 610 | return "" |
| 611 | return user_input_container[0] if user_input_container[0] is not None else "" |
| 612 | else: # Linux/macOS |
| 613 | readable_fds, _, _ = select.select([sys.stdin], [], [], timeout_seconds) |
| 614 | if readable_fds: |
| 615 | return sys.stdin.readline().strip() |
| 616 | else: |
| 617 | print("\nInput timed out. Using default value.", flush=True) |
| 618 | return "" |
| 619 | |
| 620 | |
| 621 | def get_proxy_from_gsettings(): |
no test coverage detected