mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-14 03:10:59 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
143 lines
4.1 KiB
Python
Executable File
143 lines
4.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Command-line dispatch for transcribe.sh's Python helpers.
|
|
|
|
transcribe.sh branches on the exit status, so the codes are the contract:
|
|
7 means faster_whisper is missing, 2 means a required argument is missing,
|
|
and 1 means the requested operation failed.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import logging
|
|
import sys
|
|
|
|
from _transcribe_probes import (
|
|
check_ctranslate2,
|
|
check_diarization_deps,
|
|
check_faster_whisper,
|
|
generate_sine_wav,
|
|
get_python_version,
|
|
prepare_model,
|
|
print_deps_installed,
|
|
test_cuda,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _handle_python_version() -> None:
|
|
"""Handle python-version command."""
|
|
logger.info("%s", get_python_version())
|
|
|
|
|
|
def _handle_check_faster_whisper() -> None:
|
|
"""Handle check-faster-whisper command."""
|
|
if not check_faster_whisper():
|
|
logger.error(
|
|
"Python dependency 'faster_whisper' not found in "
|
|
"offline mode. Run with --online to install.",
|
|
)
|
|
sys.exit(7)
|
|
|
|
|
|
def _handle_check_diarization() -> None:
|
|
"""Handle check-diarization command."""
|
|
check_diarization_deps()
|
|
|
|
|
|
def _handle_check_ctranslate2() -> None:
|
|
"""Handle check-ctranslate2 command."""
|
|
if not check_ctranslate2():
|
|
sys.exit(1)
|
|
|
|
|
|
def _handle_deps_installed() -> None:
|
|
"""Handle deps-installed command."""
|
|
print_deps_installed()
|
|
|
|
|
|
def _handle_generate_wav(args: argparse.Namespace) -> None:
|
|
"""Handle generate-wav command."""
|
|
if not args.file:
|
|
logger.error("--file is required for generate-wav")
|
|
sys.exit(2)
|
|
if not generate_sine_wav(args.file):
|
|
sys.exit(1)
|
|
|
|
|
|
def _handle_prepare_model(args: argparse.Namespace) -> None:
|
|
"""Handle prepare-model command."""
|
|
if not args.model or not args.model_dir:
|
|
logger.error(
|
|
"--model and --model-dir are required for prepare-model",
|
|
)
|
|
sys.exit(2)
|
|
if not prepare_model(args.model, args.model_dir):
|
|
sys.exit(1)
|
|
|
|
|
|
def _handle_test_cuda() -> None:
|
|
"""Handle test-cuda command."""
|
|
if not test_cuda():
|
|
sys.exit(1)
|
|
|
|
|
|
def main() -> None:
|
|
"""Parse arguments and dispatch helper commands."""
|
|
logging.basicConfig(format="%(message)s", level=logging.INFO)
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description="Helper utilities for transcribe.sh",
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
epilog="""
|
|
Commands:
|
|
python-version Print Python major.minor version
|
|
check-faster-whisper Check if faster_whisper is installed
|
|
check-diarization Check diarization deps (warn if missing)
|
|
check-ctranslate2 Check if ctranslate2 is installed
|
|
deps-installed Print deps installed confirmation
|
|
generate-wav FILE Generate a 3s 1kHz sine wave WAV
|
|
prepare-model Download model for offline use
|
|
test-cuda Test CUDA initialization
|
|
""",
|
|
)
|
|
parser.add_argument(
|
|
"command",
|
|
choices=[
|
|
"python-version",
|
|
"check-faster-whisper",
|
|
"check-diarization",
|
|
"check-ctranslate2",
|
|
"deps-installed",
|
|
"generate-wav",
|
|
"prepare-model",
|
|
"test-cuda",
|
|
],
|
|
help="Command to run",
|
|
)
|
|
parser.add_argument("--file", help="Output file path (for generate-wav)")
|
|
parser.add_argument("--model", help="Model name (for prepare-model)")
|
|
parser.add_argument("--model-dir", help="Model directory (for prepare-model)")
|
|
|
|
args = parser.parse_args()
|
|
|
|
dispatch: dict[str, object] = {
|
|
"python-version": _handle_python_version,
|
|
"check-faster-whisper": _handle_check_faster_whisper,
|
|
"check-diarization": _handle_check_diarization,
|
|
"check-ctranslate2": _handle_check_ctranslate2,
|
|
"deps-installed": _handle_deps_installed,
|
|
"generate-wav": lambda: _handle_generate_wav(args),
|
|
"prepare-model": lambda: _handle_prepare_model(args),
|
|
"test-cuda": _handle_test_cuda,
|
|
}
|
|
|
|
handler = dispatch.get(args.command)
|
|
if handler is not None and callable(handler):
|
|
handler()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|