25 lines
782 B
Python
25 lines
782 B
Python
#!/usr/bin/env python3
|
|
"""Verify that a directory exists and contains at least one file."""
|
|
import sys
|
|
import os
|
|
|
|
def verify_directory(path):
|
|
if not os.path.exists(path):
|
|
print(f"FAIL: Directory does not exist: {path}")
|
|
return False
|
|
if not os.path.isdir(path):
|
|
print(f"FAIL: Path is not a directory: {path}")
|
|
return False
|
|
|
|
files = os.listdir(path)
|
|
if len(files) == 0:
|
|
print(f"FAIL: Directory is empty: {path}")
|
|
return False
|
|
|
|
print(f"OK: Directory exists with {len(files)} item(s): {', '.join(files)}")
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
target = sys.argv[1] if len(sys.argv) > 1 else "/root/.hermes/wizard-outputs/spark"
|
|
success = verify_directory(target)
|
|
sys.exit(0 if success else 1) |