Get super verbose debugging logs for tracing data flow issues
()
| 7413 | return jsonify({'error': 'No data provided'}), 400 |
| 7414 | |
| 7415 | ai_reload_success = None |
| 7416 | ai_reload_error = None |
| 7417 | epd_type_changed = 'epd_type' in data |
| 7418 | |
| 7419 | # Capture pre-update kiosk state so we can detect toggles after save. |
| 7420 | prev_kiosk_enabled = bool(shared_data.config.get('kiosk_enabled', False)) |
| 7421 | # Refuse to even record kiosk_enabled on hardware that cannot host |
| 7422 | # Chromium — persisting it would leave a box permanently trying (and |
| 7423 | # failing) to install a kiosk on every boot. |
| 7424 | if data.get('kiosk_enabled'): |
| 7425 | kiosk_ok, kiosk_reason = _kiosk_capability() |
| 7426 | if not kiosk_ok: |
| 7427 | logger.warning(f"[kiosk] enable rejected: {kiosk_reason}") |
| 7428 | return jsonify({'success': False, 'error': kiosk_reason}), 400 |
| 7429 | kiosk_settings_keys = {'kiosk_url', 'kiosk_rotation', 'kiosk_hide_cursor'} |
| 7430 | kiosk_settings_changed = any( |
| 7431 | k in data and data[k] != shared_data.config.get(k) |
| 7432 | for k in kiosk_settings_keys |
| 7433 | ) |
| 7434 | |
| 7435 | # Resolve size keys (from web UI) to actual driver names |
| 7436 | if epd_type_changed: |
| 7437 | from shared import resolve_epd_type |
| 7438 | raw_epd = data['epd_type'] |
| 7439 | data['epd_type'] = resolve_epd_type(raw_epd, shared_data.config.get('epd_type')) |
| 7440 | |
| 7441 | # Update configuration (allow new keys to be added) |
| 7442 | for key, value in data.items(): |
| 7443 | # Skip private/internal keys that start with __ |
| 7444 | if not key.startswith('__'): |
| 7445 | shared_data.config[key] = value |
| 7446 | # Also set as attribute on shared_data for immediate access |
| 7447 | setattr(shared_data, key, value) |
| 7448 | |
| 7449 | if epd_type_changed: |
| 7450 | shared_data.apply_display_profile(shared_data.config.get('epd_type')) |
| 7451 | |
| 7452 | # Save configuration |
| 7453 | shared_data.save_config() |
| 7454 | |
| 7455 | # On-Screen Network Diagnostic mode and wardriving both own the e-Paper |
| 7456 | # panel + HAT keys and can't coexist (the diagnostic layer wins the |
| 7457 | # display render race). Turning diagnostic mode ON stops any live |
| 7458 | # wardriving session so the panel isn't left in a half-and-half state. |
| 7459 | if data.get('network_diagnostic_mode') is True: |
| 7460 | try: |
| 7461 | if _wardriving_engine is not None and getattr(_wardriving_engine, '_running', False): |
| 7462 | logger.info("Stopping wardriving: On-Screen Network Diagnostic mode enabled (mutually exclusive).") |
| 7463 | _wardriving_engine.stop() |
| 7464 | except Exception as e: |
| 7465 | logger.warning(f"Could not stop wardriving when enabling diagnostic mode: {e}") |
| 7466 | |
| 7467 | # Auto-install pyserial when wardriving is enabled |
| 7468 | if data.get('wardriving_enabled') is True: |
| 7469 | try: |
| 7470 | import serial # noqa: F401 |
| 7471 | except ImportError: |
| 7472 | # NB: no local `import subprocess` here — a function-local |
nothing calls this directly
no test coverage detected