Spaces:
Running
Running
dark mode, concise message
Browse files- demo/health.py +10 -18
- demo/layout.py +20 -0
demo/health.py
CHANGED
|
@@ -45,7 +45,7 @@ def _version_at_least(raw: str, expected: tuple[int, ...]) -> bool:
|
|
| 45 |
|
| 46 |
|
| 47 |
def _check_deno() -> ToolStatus:
|
| 48 |
-
label = "
|
| 49 |
binary = shutil.which("deno")
|
| 50 |
if not binary:
|
| 51 |
return ToolStatus(label, False, "`deno` command not found on PATH")
|
|
@@ -72,7 +72,7 @@ def _check_deno() -> ToolStatus:
|
|
| 72 |
|
| 73 |
|
| 74 |
def _check_yt_dlp_python() -> ToolStatus:
|
| 75 |
-
label = "
|
| 76 |
try:
|
| 77 |
import yt_dlp
|
| 78 |
from yt_dlp import YoutubeDL
|
|
@@ -91,8 +91,9 @@ def _check_yt_dlp_python() -> ToolStatus:
|
|
| 91 |
return ToolStatus(label, False, f"Detected {version_str}; require β₯ {minimum}")
|
| 92 |
|
| 93 |
has_ejs = importlib.util.find_spec("yt_dlp_ejs") is not None
|
| 94 |
-
|
| 95 |
-
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
def run_health_report() -> HealthReport:
|
|
@@ -112,24 +113,15 @@ def _sanitize(text: str) -> str:
|
|
| 112 |
|
| 113 |
def render_health_notice() -> str:
|
| 114 |
report = run_health_report()
|
| 115 |
-
if report.ok
|
| 116 |
-
bg = "#dcfce7"
|
| 117 |
-
border = "#86efac"
|
| 118 |
-
text_color = "#14532d"
|
| 119 |
-
icon = "β
"
|
| 120 |
-
else:
|
| 121 |
-
bg = "#fee2e2"
|
| 122 |
-
border = "#fecaca"
|
| 123 |
-
text_color = "#7f1d1d"
|
| 124 |
-
icon = "π§―"
|
| 125 |
bullet_rows = "".join(
|
| 126 |
-
f"<li>{_sanitize(status.label)}: "
|
| 127 |
-
f"<strong>{'Ready' if status.ok else 'Needs attention'}</strong>
|
| 128 |
-
f"{_sanitize(status.detail)}</li>"
|
| 129 |
for status in report.tools
|
| 130 |
)
|
| 131 |
return (
|
| 132 |
-
f"<div class='health-box
|
| 133 |
f"<div class='health-head'>{icon} {_sanitize(report.summary)}</div>"
|
| 134 |
f"<ul>{bullet_rows}</ul>"
|
| 135 |
"</div>"
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
def _check_deno() -> ToolStatus:
|
| 48 |
+
label = "Deno"
|
| 49 |
binary = shutil.which("deno")
|
| 50 |
if not binary:
|
| 51 |
return ToolStatus(label, False, "`deno` command not found on PATH")
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
def _check_yt_dlp_python() -> ToolStatus:
|
| 75 |
+
label = "yt-dlp"
|
| 76 |
try:
|
| 77 |
import yt_dlp
|
| 78 |
from yt_dlp import YoutubeDL
|
|
|
|
| 91 |
return ToolStatus(label, False, f"Detected {version_str}; require β₯ {minimum}")
|
| 92 |
|
| 93 |
has_ejs = importlib.util.find_spec("yt_dlp_ejs") is not None
|
| 94 |
+
if has_ejs:
|
| 95 |
+
return ToolStatus(label, True, f"v{version_str}")
|
| 96 |
+
return ToolStatus(label, False, "yt_dlp_ejs missing (JS sites will fail)")
|
| 97 |
|
| 98 |
|
| 99 |
def run_health_report() -> HealthReport:
|
|
|
|
| 113 |
|
| 114 |
def render_health_notice() -> str:
|
| 115 |
report = run_health_report()
|
| 116 |
+
state_class, icon = ("health-success", "β
") if report.ok else ("health-fail", "π§―")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
bullet_rows = "".join(
|
| 118 |
+
f"<li>{'β
' if status.ok else 'β'} {_sanitize(status.label)}: "
|
| 119 |
+
f"<strong>{'Ready' if status.ok else 'Needs attention'}</strong>"
|
| 120 |
+
f"{'' if not status.detail else ' β ' + _sanitize(status.detail)}</li>"
|
| 121 |
for status in report.tools
|
| 122 |
)
|
| 123 |
return (
|
| 124 |
+
f"<div class='health-box {state_class}'>"
|
| 125 |
f"<div class='health-head'>{icon} {_sanitize(report.summary)}</div>"
|
| 126 |
f"<ul>{bullet_rows}</ul>"
|
| 127 |
"</div>"
|
demo/layout.py
CHANGED
|
@@ -18,6 +18,16 @@ CELL_CSS = """
|
|
| 18 |
padding: 18px;
|
| 19 |
border: 1px solid transparent;
|
| 20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
.health-box ul {
|
| 22 |
margin: 12px 0 0;
|
| 23 |
padding-left: 22px;
|
|
@@ -34,6 +44,16 @@ CELL_CSS = """
|
|
| 34 |
.cell-wrapper {
|
| 35 |
border-color: rgba(255, 255, 255, 0.45);
|
| 36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
.health-placeholder {
|
| 38 |
background: rgba(148, 163, 184, 0.15) !important;
|
| 39 |
border-color: rgba(148, 163, 184, 0.4) !important;
|
|
|
|
| 18 |
padding: 18px;
|
| 19 |
border: 1px solid transparent;
|
| 20 |
}
|
| 21 |
+
.health-success {
|
| 22 |
+
background: #dcfce7;
|
| 23 |
+
border-color: #86efac;
|
| 24 |
+
color: #14532d;
|
| 25 |
+
}
|
| 26 |
+
.health-fail {
|
| 27 |
+
background: #fee2e2;
|
| 28 |
+
border-color: #fecaca;
|
| 29 |
+
color: #7f1d1d;
|
| 30 |
+
}
|
| 31 |
.health-box ul {
|
| 32 |
margin: 12px 0 0;
|
| 33 |
padding-left: 22px;
|
|
|
|
| 44 |
.cell-wrapper {
|
| 45 |
border-color: rgba(255, 255, 255, 0.45);
|
| 46 |
}
|
| 47 |
+
.health-success {
|
| 48 |
+
background: rgba(74, 222, 128, 0.12);
|
| 49 |
+
border-color: rgba(74, 222, 128, 0.55);
|
| 50 |
+
color: #ecfdf3;
|
| 51 |
+
}
|
| 52 |
+
.health-fail {
|
| 53 |
+
background: rgba(248, 113, 113, 0.12);
|
| 54 |
+
border-color: rgba(248, 113, 113, 0.6);
|
| 55 |
+
color: #fee2e2;
|
| 56 |
+
}
|
| 57 |
.health-placeholder {
|
| 58 |
background: rgba(148, 163, 184, 0.15) !important;
|
| 59 |
border-color: rgba(148, 163, 184, 0.4) !important;
|