heatmap / scripts /verify_project.py
Ndg07's picture
Feat: 24-hour cleanup for local SQLite
c293f7c
#!/usr/bin/env python3
"""
Project verification script to check if everything is ready for git push and deployment
"""
import os
import sys
import subprocess
from pathlib import Path
def check_file_exists(file_path, description):
"""Check if a file exists"""
if os.path.exists(file_path):
print(f"βœ… {description}: {file_path}")
return True
else:
print(f"❌ {description}: {file_path} - NOT FOUND")
return False
def check_directory_exists(dir_path, description):
"""Check if a directory exists"""
if os.path.isdir(dir_path):
print(f"βœ… {description}: {dir_path}")
return True
else:
print(f"❌ {description}: {dir_path} - NOT FOUND")
return False
def check_python_syntax(file_path):
"""Check Python file syntax"""
try:
with open(file_path, 'r', encoding='utf-8') as f:
compile(f.read(), file_path, 'exec')
return True
except SyntaxError as e:
print(f"❌ Syntax error in {file_path}: {e}")
return False
except Exception as e:
print(f"⚠️ Warning in {file_path}: {e}")
return True
def main():
"""Main verification function"""
print("πŸ” Enhanced Fake News Detection System - Project Verification")
print("=" * 70)
all_checks_passed = True
# Check core project structure
print("\nπŸ“ Project Structure:")
structure_checks = [
("backend/", "Backend directory"),
("frontend/", "Frontend directory"),
("docs/", "Documentation directory"),
("map/", "Map assets directory"),
("data/", "Data directory"),
("tests/", "Tests directory"),
("scripts/", "Scripts directory"),
]
for path, desc in structure_checks:
if not check_directory_exists(path, desc):
all_checks_passed = False
# Check essential files
print("\nπŸ“„ Essential Files:")
file_checks = [
("README.md", "Main README"),
("requirements.txt", "Main requirements"),
("Dockerfile", "Docker configuration"),
("docker-compose.yml", "Docker Compose dev"),
("docker-compose.prod.yml", "Docker Compose prod"),
(".gitignore", "Git ignore file"),
("backend/main_application.py", "Main backend application"),
("backend/requirements.txt", "Backend requirements"),
("docs/README.md", "Documentation index"),
]
for path, desc in file_checks:
if not check_file_exists(path, desc):
all_checks_passed = False
# Check Python syntax in key files
print("\n🐍 Python Syntax Check:")
python_files = [
"backend/main_application.py",
"backend/enhanced_fake_news_detector.py",
"backend/advanced_ml_classifier.py",
"backend/api.py",
]
for py_file in python_files:
if os.path.exists(py_file):
if check_python_syntax(py_file):
print(f"βœ… Syntax OK: {py_file}")
else:
all_checks_passed = False
else:
print(f"⚠️ File not found: {py_file}")
# Check documentation completeness
print("\nπŸ“š Documentation Check:")
doc_files = [
"docs/BACKEND_ARCHITECTURE.md",
"docs/ML_MODEL_DOCUMENTATION.md",
"docs/PROJECT_STRUCTURE.md",
"docs/SYSTEM_OVERVIEW.md",
]
for doc_file in doc_files:
if not check_file_exists(doc_file, f"Documentation: {doc_file}"):
all_checks_passed = False
# Check for cleaned up files (should not exist)
print("\n🧹 Cleanup Verification:")
should_not_exist = [
"backend/main_ibmcloud.py",
"backend/watson_client.py",
"backend/pubsub_emulator.py",
"cloud/",
"demo_api_test.py",
"test_system_working.py",
"debug_map.html",
]
cleanup_ok = True
for path in should_not_exist:
if os.path.exists(path):
print(f"❌ Should be removed: {path}")
cleanup_ok = False
if cleanup_ok:
print("βœ… All unnecessary files have been cleaned up")
else:
all_checks_passed = False
# Check git status
print("\nπŸ“¦ Git Status:")
try:
result = subprocess.run(['git', 'status', '--porcelain'],
capture_output=True, text=True, check=True)
if result.stdout.strip():
print("πŸ“ Uncommitted changes found:")
print(result.stdout)
else:
print("βœ… Working directory is clean")
except subprocess.CalledProcessError:
print("⚠️ Could not check git status")
except FileNotFoundError:
print("⚠️ Git not found")
# Final result
print("\n" + "=" * 70)
if all_checks_passed:
print("πŸŽ‰ PROJECT VERIFICATION PASSED!")
print("βœ… Project is ready for git push and deployment")
return 0
else:
print("❌ PROJECT VERIFICATION FAILED!")
print("πŸ”§ Please fix the issues above before proceeding")
return 1
if __name__ == "__main__":
sys.exit(main())