1
0

updates check

This commit is contained in:
2024-12-18 20:19:25 +01:00
parent b2277e54f6
commit baa4453eb0
+33 -3
View File
@@ -7,6 +7,7 @@ import subprocess
import configparser
from pathlib import Path
from typing import Dict, List, Tuple
import importlib
# Unicode emoji
CHECK = "✅"
@@ -20,6 +21,14 @@ def check_env_var(var: str) -> Tuple[bool, str]:
"""Check if an environment variable is set."""
return (var in os.environ, f"Environment variable '{var}' not set")
def check_python_lib(lib: str) -> Tuple[bool, str]:
"""Check if a Python library is available."""
try:
importlib.import_module(lib.split('.')[0])
return (True, f"Python library '{lib}' found")
except ImportError:
return (False, f"Python library '{lib}' not found")
def check_stats_commands() -> List[Tuple[bool, str]]:
"""Check if all stat commands in config can run."""
results = []
@@ -58,11 +67,9 @@ def check_stats_collector_config() -> List[Tuple[bool, str]]:
def check_scripts() -> Dict[str, List[Tuple[bool, str]]]:
"""Run all checks for each script."""
checks = {
"av1": [
check_command("ffmpeg"),
],
"e-ink": [
check_command("python3"),
check_python_lib("PIL"),
],
"indeel": [
check_command("file"),
@@ -76,25 +83,48 @@ def check_scripts() -> Dict[str, List[Tuple[bool, str]]]:
check_env_var("PUSHOVER_APP_TOKEN"),
check_env_var("PUSHOVER_USER_TOKEN"),
check_command("curl"),
check_python_lib("requests"),
],
"stats": [
check_command("python3"),
check_command("sensors"),
check_command("jq"),
check_command("top"),
check_command("free"),
check_command("df"),
check_python_lib("configparser"),
check_python_lib("http.server"),
*check_stats_commands(),
],
"stats-collector": [
check_command("python3"),
check_python_lib("sqlalchemy"),
check_python_lib("requests"),
*check_stats_collector_config(),
],
"syncwall": [
check_command("wget"),
check_command("wal"),
],
"tclean": [
check_command("python3"),
check_command("transmission-remote"),
check_python_lib("argparse"),
check_python_lib("datetime"),
],
"vc": [
check_command("ffmpeg"),
check_command("yt-dlp"),
check_python_lib("argparse"),
],
"vcmp": [
check_command("ffmpeg"),
check_command("ffprobe"),
check_command("nice"),
check_python_lib("pathlib"),
check_python_lib("argparse"),
check_python_lib("logging"),
check_python_lib("tempfile"),
],
}
return checks