File size: 4,971 Bytes
623e14e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Verification script for the Enhanced DOCX to PDF Converter
"""

import os
import sys
from pathlib import Path

def verify_directory_structure():
    """Verify that all required directories and files exist"""
    print("Verifying directory structure...")
    
    required_dirs = [
        "src",
        "src/api",
        "src/utils",
        "tests",
        "conversions"
    ]
    
    required_files = [
        "src/api/main.py",
        "src/api/app.py",
        "src/utils/config.py",
        "src/utils/converter.py",
        "src/utils/file_handler.py",
        "tests/test_converter.py",
        "Dockerfile",
        "docker-compose.yml",
        "requirements.txt",
        "README.md"
    ]
    
    # Check directories
    for dir_path in required_dirs:
        if not os.path.exists(dir_path):
            print(f"❌ Missing directory: {dir_path}")
            return False
        print(f"✅ Found directory: {dir_path}")
    
    # Check files
    for file_path in required_files:
        if not os.path.exists(file_path):
            print(f"❌ Missing file: {file_path}")
            return False
        print(f"✅ Found file: {file_path}")
    
    return True

def verify_python_compilation():
    """Verify that all Python files compile without syntax errors"""
    print("\nVerifying Python compilation...")
    
    python_files = [
        "src/api/main.py",
        "src/api/app.py",
        "src/utils/config.py",
        "src/utils/converter.py",
        "src/utils/file_handler.py",
        "tests/test_converter.py"
    ]
    
    for file_path in python_files:
        try:
            with open(file_path, 'r', encoding='utf-8') as f:
                compile(f.read(), file_path, 'exec')
            print(f"✅ Compiles successfully: {file_path}")
        except Exception as e:
            print(f"❌ Compilation error in {file_path}: {e}")
            return False
    
    return True

def verify_docker_files():
    """Verify Docker configuration files"""
    print("\nVerifying Docker configuration...")
    
    # Check if Dockerfile exists and is readable
    try:
        with open("Dockerfile", "r") as f:
            content = f.read()
            if "FROM ubuntu:22.04" in content and "libreoffice" in content:
                print("✅ Dockerfile appears to be correctly configured")
            else:
                print("⚠️ Dockerfile may be missing key components")
    except Exception as e:
        print(f"❌ Error reading Dockerfile: {e}")
        return False
    
    # Check if docker-compose.yml exists and is readable
    try:
        with open("docker-compose.yml", "r") as f:
            content = f.read()
            if "docx-to-pdf-enhanced" in content and "8000:8000" in content:
                print("✅ docker-compose.yml appears to be correctly configured")
            else:
                print("⚠️ docker-compose.yml may be missing key components")
    except Exception as e:
        print(f"❌ Error reading docker-compose.yml: {e}")
        return False
    
    return True

def verify_requirements():
    """Verify requirements file"""
    print("\nVerifying requirements...")
    
    try:
        with open("requirements.txt", "r") as f:
            content = f.read()
            required_packages = ["fastapi", "uvicorn", "python-multipart"]
            
            for package in required_packages:
                if package in content:
                    print(f"✅ Found required package: {package}")
                else:
                    print(f"❌ Missing required package: {package}")
                    return False
                    
        print("✅ All required packages found in requirements.txt")
        return True
    except Exception as e:
        print(f"❌ Error reading requirements.txt: {e}")
        return False

def main():
    """Main verification function"""
    print("Enhanced DOCX to PDF Converter - Setup Verification")
    print("=" * 50)
    
    # Run all verification checks
    checks = [
        verify_directory_structure,
        verify_python_compilation,
        verify_docker_files,
        verify_requirements
    ]
    
    all_passed = True
    for check in checks:
        if not check():
            all_passed = False
    
    print("\n" + "=" * 50)
    if all_passed:
        print("✅ All verification checks passed!")
        print("\nYour Enhanced DOCX to PDF Converter is ready for use.")
        print("To start the service, run:")
        print("  docker-compose up --build")
        print("\nThen access the API at http://localhost:8000")
        print("API documentation is available at http://localhost:8000/docs")
    else:
        print("❌ Some verification checks failed.")
        print("Please review the errors above and correct them before proceeding.")
    
    return all_passed

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)