File size: 4,869 Bytes
95e10ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""

Check if all debugging features are properly integrated.

"""

import os
import sys
import importlib.util

def check_file_exists(filename):
    """Check if a file exists."""
    exists = os.path.isfile(filename)
    status = "βœ“" if exists else "βœ—"
    print(f"{status} {filename}: {'Found' if exists else 'Missing'}")
    return exists

def check_import(module_name):
    """Check if a module can be imported."""
    try:
        spec = importlib.util.find_spec(module_name)
        if spec is not None:
            module = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(module)
            print(f"βœ“ {module_name}: Import successful")
            return True
        else:
            print(f"βœ— {module_name}: Module not found")
            return False
    except Exception as e:
        print(f"βœ— {module_name}: Import failed - {e}")
        return False

def check_debug_routes():
    """Check if debug routes are properly integrated."""
    try:
        # Try to import the app and check for debug routes
        spec = importlib.util.find_spec('app')
        if spec is not None:
            print("βœ“ app.py: Found")
            
            # Check if debug_routes can be imported
            if check_import('debug_routes'):
                print("βœ“ Debug routes: Integration successful")
                return True
            else:
                print("βœ— Debug routes: Integration failed")
                return False
        else:
            print("βœ— app.py: Not found")
            return False
    except Exception as e:
        print(f"βœ— Debug routes check failed: {e}")
        return False

def check_logging_config():
    """Check if logging configuration is properly integrated."""
    try:
        if check_import('logging_config'):
            print("βœ“ Logging configuration: Integration successful")
            return True
        else:
            print("βœ— Logging configuration: Integration failed")
            return False
    except Exception as e:
        print(f"βœ— Logging configuration check failed: {e}")
        return False

def main():
    """Main function."""
    print("HealthGuard-AI Debug Integration Check")
    print("=" * 40)
    
    # Required files
    required_files = [
        'app.py',
        'debug_routes.py',
        'logging_config.py',
        'login_debug.py',
        'test_login_flow.py',
        'exact_login_test.py',
        'simple_login_test.py',
        'production_login_diagnostic.py',
        'deployment_test.py',
        'verify_deployment.py',
        'run_diagnostics.py',
        'post_deployment_test.py',
        'start_debug.py'
    ]
    
    print("Checking required files:")
    missing_files = []
    for filename in required_files:
        if not check_file_exists(filename):
            missing_files.append(filename)
    
    print()
    
    # Check imports
    print("Checking module imports:")
    modules_to_check = [
        'debug_routes',
        'logging_config',
        'login_debug',
        'verify_deployment'
    ]
    
    failed_imports = []
    for module in modules_to_check:
        if not check_import(module):
            failed_imports.append(module)
    
    print()
    
    # Check specific integrations
    print("Checking specific integrations:")
    debug_routes_ok = check_debug_routes()
    logging_config_ok = check_logging_config()
    
    print()
    
    # Summary
    print("INTEGRATION CHECK SUMMARY")
    print("=" * 40)
    
    total_checks = len(required_files) + len(modules_to_check) + 2  # +2 for debug routes and logging config
    passed_checks = (len(required_files) - len(missing_files)) + (len(modules_to_check) - len(failed_imports)) + (1 if debug_routes_ok else 0) + (1 if logging_config_ok else 0)
    
    print(f"Files: {len(required_files) - len(missing_files)}/{len(required_files)} present")
    print(f"Imports: {len(modules_to_check) - len(failed_imports)}/{len(modules_to_check)} successful")
    print(f"Integrations: {2 if (debug_routes_ok and logging_config_ok) else (1 if (debug_routes_ok or logging_config_ok) else 0)}/2 successful")
    print(f"Overall: {passed_checks}/{total_checks} checks passed")
    
    if missing_files:
        print(f"\nMissing files: {', '.join(missing_files)}")
    
    if failed_imports:
        print(f"Failed imports: {', '.join(failed_imports)}")
    
    if passed_checks == total_checks:
        print("\nβœ“ All debugging features are properly integrated!")
        return True
    else:
        print("\nβœ— Some debugging features are missing or not properly integrated.")
        return False

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