#!/usr/bin/env python3 """Count files in a directory, excluding subdirectories.""" import sys import os def count_files(path): if not os.path.exists(path): print(f"ERROR: Path does not exist: {path}") return -1 if not os.path.isdir(path): print(f"ERROR: Path is not a directory: {path}") return -1 count = 0 for entry in os.listdir(path): full_path = os.path.join(path, entry) if os.path.isfile(full_path): count += 1 print(f"FILE_COUNT:{count}") return count if __name__ == "__main__": target = sys.argv[1] if len(sys.argv) > 1 else "/root/.hermes/wizard-outputs/spark" result = count_files(target) sys.exit(0 if result >= 0 else 1)