MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / update_config

Function update_config

webapp_modern.py:4894–5018  ·  view source on GitHub ↗

Update configuration

()

Source from the content-addressed store, hash-verified

4892 for entry in pwd.getpwall():
4893 if 1000 <= entry.pw_uid < 65534:
4894 p = os.path.join(entry.pw_dir, KIOSK_AUTOSTART_REL)
4895 if os.path.exists(p):
4896 paths.append(p)
4897 except Exception:
4898 pass
4899 return paths
4900
4901
4902# Kiosk install/teardown runs on a background thread and can take many minutes
4903# on a slow board — the installer apt-installs chromium. The UI polls
4904# /api/kiosk/status while that happens, so the task's progress and any failure
4905# have to be visible there. Without it the API reported 'not_installed' for the
4906# whole install, which is indistinguishable from "nothing happened", and the UI
4907# gave up after ~25s on a job that was running fine.
4908_kiosk_task = {'busy': False, 'phase': 'idle', 'error': None, 'started': 0.0}
4909_kiosk_task_lock = threading.Lock()
4910
4911
4912def _kiosk_task_set(**kw) -> None:
4913 with _kiosk_task_lock:
4914 _kiosk_task.update(kw)
4915
4916
4917def _kiosk_task_get() -> dict:
4918 with _kiosk_task_lock:
4919 return dict(_kiosk_task)
4920
4921
4922def _kiosk_mode() -> str:
4923 """Return 'service', 'autostart', or 'not_installed' based on what's on disk."""
4924 if _kiosk_autostart_paths():
4925 return 'autostart'
4926 if os.path.exists(KIOSK_SERVICE_FILE):
4927 return 'service'
4928 return 'not_installed'
4929
4930
4931def _kiosk_running() -> bool:
4932 """Best-effort: is a kiosk chromium process running right now?"""
4933 try:
4934 proc = subprocess.run(
4935 ['pgrep', '-f', 'ragnar-kiosk-chromium'],
4936 capture_output=True, text=True, timeout=5, check=False
4937 )
4938 return proc.returncode == 0 and bool(proc.stdout.strip())
4939 except Exception:
4940 return False
4941
4942
4943def _x11_display_for(uid: int) -> str:
4944 """The DISPLAY of this user's X session, via loginctl. '&#x27; when there is none.
4945
4946 Pi OS Desktop is Wayland now, but plenty of boxes still run X11 — the user
4947 switched it in raspi-config, or the image predates labwc. Those sessions have
4948 no wayland-* socket at all, which is the only thing the spawn used to look
4949 for, so enabling the kiosk from the web UI appeared to do nothing until the
4950 person at the screen logged out and back in.
4951 """

Callers

nothing calls this directly

Calls 14

resolve_epd_typeFunction · 0.90
normalize_rotationFunction · 0.90
apply_display_profileMethod · 0.80
save_configMethod · 0.80
infoMethod · 0.80
warningMethod · 0.80
initialize_ai_serviceMethod · 0.80
reload_tokenMethod · 0.80
emitMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected