Fix shell details: distro name, storage path only in footer
- OS name comes from /etc/os-release (e.g. 'CachyOS Linux'), mirroring the original app's os_utils; macOS/Windows get proper names too - Status pill shows the name as-is instead of uppercasing it - Removed the watched-folder path next to the logo; it now appears only in the footer strip (spec updated to match)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import platform
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _os_release_values():
|
||||
values = {}
|
||||
try:
|
||||
with open("/etc/os-release", encoding="utf-8") as handle:
|
||||
for line in handle:
|
||||
line = line.strip()
|
||||
if not line or "=" not in line:
|
||||
continue
|
||||
key, value = line.split("=", 1)
|
||||
values[key] = value.strip().strip('"')
|
||||
except OSError:
|
||||
pass
|
||||
return values
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def get_os_info():
|
||||
"""OS display name and icon key, mirroring the original app's os_utils."""
|
||||
system = platform.system()
|
||||
release = platform.release()
|
||||
if system == "Linux":
|
||||
name = _os_release_values().get("NAME") or "Linux"
|
||||
return {"name": name, "release": release, "icon": "linux"}
|
||||
if system == "Darwin":
|
||||
return {"name": "macOS", "release": release, "icon": "apple"}
|
||||
if system == "Windows":
|
||||
return {"name": "Windows", "release": release, "icon": "windows"}
|
||||
return {"name": system, "release": release, "icon": "unknown"}
|
||||
@@ -1,4 +1,3 @@
|
||||
import platform
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
@@ -6,13 +5,7 @@ from rest_framework.permissions import AllowAny
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
|
||||
def _os_info():
|
||||
system = platform.system()
|
||||
icon = {"Linux": "linux", "Darwin": "apple", "Windows": "windows"}.get(
|
||||
system, "unknown"
|
||||
)
|
||||
return {"name": system, "release": platform.release(), "icon": icon}
|
||||
from .system_info import get_os_info
|
||||
|
||||
|
||||
def _worker_counts():
|
||||
@@ -35,7 +28,7 @@ class StatusView(APIView):
|
||||
"env": settings.APP_ENV,
|
||||
"git_hash": settings.GIT_COMMIT_HASH,
|
||||
"version": settings.APP_VERSION,
|
||||
"os": _os_info(),
|
||||
"os": get_os_info(),
|
||||
"watched_folder": settings.WATCHED_FOLDER,
|
||||
"e621_time_ms": None, # no e621 calls in the backend yet
|
||||
"workers": _worker_counts(),
|
||||
|
||||
Reference in New Issue
Block a user