Attach the right handler for a newly-classified device.
(self, role, node)
| 2040 | active = subprocess.run( |
| 2041 | ['systemctl', 'is-active', '--quiet', 'gpsd.socket'], |
| 2042 | timeout=5).returncode == 0 |
| 2043 | |
| 2044 | try: |
| 2045 | from gps_manager import detect_gps_device |
| 2046 | dev = detect_gps_device(exclude_ports=esp_exclude or None) |
| 2047 | except Exception: |
| 2048 | dev = None |
| 2049 | # 'gpsd' is the sentinel for "gpsd already running and owns the port", |
| 2050 | # not a device path — treat as already-configured, don't re-point. |
| 2051 | if dev == 'gpsd': |
| 2052 | dev = None |
| 2053 | want = os.path.realpath(dev) if dev else None |
| 2054 | needs_setup = bool(want) and want != self._gpsd_configured_realpath() |
| 2055 | |
| 2056 | if needs_setup or not active: |
| 2057 | setup = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 2058 | 'scripts', 'setup_gpsd.sh') |
| 2059 | if os.path.isfile(setup): |
| 2060 | subprocess.run(['sudo', 'bash', setup], timeout=30, check=False, |
no test coverage detected