import shutil from pathlib import Path from config import DATA_DIR, BASE_DIR def get_disk_usage() -> float | str: try: stat = shutil.disk_usage(DATA_DIR) return round(stat.free / (1024**3), 2) except: return "?" def get_entwine_path() -> str | None: import subprocess try: result = subprocess.run(["which", "entwine"], capture_output=True, text=True, check=False) if result.returncode == 0: path = result.stdout.strip() if path and Path(path).exists(): return path except Exception: pass common_paths = [ "/usr/local/bin/entwine", "/usr/bin/entwine", str(BASE_DIR / "entwine"), str(BASE_DIR / "bin" / "entwine"), ] for path in common_paths: if Path(path).exists(): return path return None