File size: 5,172 Bytes
c293f7c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #!/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()) |