Get network scan data from SQLite database - returns ALL hosts (alive and degraded).
()
| 5792 | _stop_service('ragnar.service') |
| 5793 | |
| 5794 | |
| 5795 | def _show_epaper_transition(message: str) -> None: |
| 5796 | """Write a transition message to the e-paper display before swapping services.""" |
| 5797 | try: |
| 5798 | display = getattr(shared_data, 'display_instance', None) |
| 5799 | if not display: |
| 5800 | return |
| 5801 | epd_helper = getattr(shared_data, 'epd_helper', None) |
| 5802 | if not epd_helper: |
| 5803 | return |
| 5804 | |
| 5805 | from PIL import Image, ImageDraw, ImageFont |
| 5806 | width = shared_data.config.get('ref_width', 122) |
| 5807 | height = shared_data.config.get('ref_height', 250) |
| 5808 | image = Image.new('1', (height, width), 255) # landscape orientation |
| 5809 | draw = ImageDraw.Draw(image) |
| 5810 | |
| 5811 | # Use system font or fallback |
| 5812 | try: |
| 5813 | font = ImageFont.truetype(getattr(shared_data, 'font_arial_path', '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf'), 14) |
| 5814 | font_small = ImageFont.truetype(getattr(shared_data, 'font_arial_path', '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'), 10) |
| 5815 | except Exception: |
| 5816 | font = ImageFont.load_default() |
| 5817 | font_small = font |
| 5818 | |
| 5819 | # Center the message |
| 5820 | draw.text((10, width // 2 - 20), message, font=font, fill=0) |
| 5821 | draw.text((10, width // 2 + 5), "Please wait...", font=font_small, fill=0) |
| 5822 | |
| 5823 | # Handle screen rotation |
| 5824 | from shared import normalize_rotation |
| 5825 | _rotation = normalize_rotation(shared_data.config.get('screen_reversed', 0)) |
| 5826 | if _rotation: |
| 5827 | image = image.rotate(_rotation, expand=True) |
| 5828 | |
| 5829 | epd_helper.display_full(image) |
| 5830 | logger.info(f"E-paper transition: {message}") |
| 5831 | except Exception as e: |
| 5832 | logger.debug(f"E-paper transition message failed (non-fatal): {e}") |
| 5833 | |
| 5834 | |
| 5835 | def _execute_pwn_mode_switch(target_mode: str) -> None: |
| 5836 | logger.info(f"Preparing service handoff to {target_mode}") |
| 5837 | time.sleep(PWN_SWAP_DELAY_SECONDS) |
| 5838 | |
| 5839 | if target_mode == 'pwnagotchi': |
| 5840 | _ensure_pwn_launcher() |
| 5841 | # Re-sync the launcher-readable flag with the saved preference so the |
| 5842 | # service starts in the mode the user selected in the web UI. |
| 5843 | _set_pwn_manual_mode(bool(shared_data.config.get('pwnagotchi_manual_mode', False))) |
| 5844 | |
| 5845 | # Stop the display loop FIRST so it doesn't overwrite the transition message. |
| 5846 | # E-paper retains its image without power, so the message stays visible. |
| 5847 | shared_data.display_should_exit = True |
| 5848 | |
| 5849 | # Show transition message on e-paper before Ragnar stops. |
| 5850 | # Run in a thread with a timeout so a blocked SPI bus never hangs the swap. |
| 5851 | _epd_t = threading.Thread(target=_show_epaper_transition, args=("Switching to Pwnagotchi...",), daemon=True) |
nothing calls this directly
no test coverage detected