first version check script
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check if all scripts and their dependencies are properly configured."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import configparser
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
# Unicode emoji
|
||||
CHECK = "✅"
|
||||
CROSS = "❌"
|
||||
|
||||
def check_command(cmd: str) -> Tuple[bool, str]:
|
||||
"""Check if a command is available in PATH."""
|
||||
return (shutil.which(cmd) is not None, f"Command '{cmd}' not found")
|
||||
|
||||
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_stats_commands() -> List[Tuple[bool, str]]:
|
||||
"""Check if all stat commands in config can run."""
|
||||
results = []
|
||||
config_home = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||
config_path = Path(config_home) / "stats/config.ini"
|
||||
|
||||
if not config_path.exists():
|
||||
return [(False, f"Stats config not found at {config_path}")]
|
||||
|
||||
config = configparser.ConfigParser(interpolation=None)
|
||||
config.read(config_path)
|
||||
|
||||
for section in config.sections():
|
||||
if section.startswith('stat.'):
|
||||
cmd = config[section]['command']
|
||||
try:
|
||||
subprocess.run(cmd, shell=True, capture_output=True, check=True)
|
||||
results.append((True, f"Command '{cmd}' runs successfully"))
|
||||
except subprocess.CalledProcessError:
|
||||
results.append((False, f"Command '{cmd}' failed to run"))
|
||||
|
||||
return results
|
||||
|
||||
def check_scripts() -> Dict[str, List[Tuple[bool, str]]]:
|
||||
"""Run all checks for each script."""
|
||||
checks = {
|
||||
"av1": [
|
||||
check_command("ffmpeg"),
|
||||
],
|
||||
"indeel": [
|
||||
check_command("file"),
|
||||
check_command("magick"),
|
||||
check_command("dctfilename"),
|
||||
check_command("webpmux"),
|
||||
check_command("gifski"),
|
||||
],
|
||||
"mover": [], # No specific dependencies
|
||||
"pushover": [
|
||||
check_env_var("PUSHOVER_APP_TOKEN"),
|
||||
check_env_var("PUSHOVER_USER_TOKEN"),
|
||||
check_command("curl"),
|
||||
],
|
||||
"stats": check_stats_commands(),
|
||||
"syncwall": [
|
||||
check_command("wget"),
|
||||
check_command("wal"),
|
||||
],
|
||||
"vc": [
|
||||
check_command("ffmpeg"),
|
||||
check_command("yt-dlp"),
|
||||
],
|
||||
"vcmp": [
|
||||
check_command("ffmpeg"),
|
||||
check_command("ffprobe"),
|
||||
],
|
||||
}
|
||||
return checks
|
||||
|
||||
def main():
|
||||
results = check_scripts()
|
||||
|
||||
print("Script Status Check")
|
||||
print("==================")
|
||||
|
||||
for script, checks in results.items():
|
||||
all_passed = all(result[0] for result in checks) if checks else True
|
||||
status = CHECK if all_passed else CROSS
|
||||
print(f"\n{status} {script}")
|
||||
|
||||
if not checks:
|
||||
print(" No specific requirements")
|
||||
else:
|
||||
for passed, message in checks:
|
||||
status = CHECK if passed else CROSS
|
||||
if not passed:
|
||||
print(f" {status} {message}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user