File size: 3,595 Bytes
7b7bdab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Final verification script for process.py fixes
"""
import os
import sys
import subprocess
import time

def main():
    print("=== Process.py Fix Verification ===")
    print(f"Working directory: {os.getcwd()}")
    print(f"Python version: {sys.version}")
    
    # Test 1: Import test
    print("\n1. Testing imports...")
    try:
        # Test the robust version first
        sys.path.insert(0, '/workspaces/fastapi_django_main_live')
        import process_robust
        
        # Test basic functions
        base_path = process_robust.get_base_path_safe()
        print(f"βœ… Robust version working: {base_path}")
        
        # Test path creation
        success = process_robust.ensure_base_path_exists()
        print(f"βœ… Path creation: {success}")
        
    except Exception as e:
        print(f"❌ Robust version failed: {e}")
        return False
    
    # Test 2: Original process.py with Django
    print("\n2. Testing original process.py...")
    try:
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
        import django
        django.setup()
        
        from mysite.interpreter.process import get_base_path, ensure_base_path_exists
        
        original_base_path = get_base_path()
        print(f"βœ… Original get_base_path: {original_base_path}")
        
        original_success = ensure_base_path_exists()
        print(f"βœ… Original path creation: {original_success}")
        
    except Exception as e:
        print(f"❌ Original process.py failed: {e}")
        import traceback
        traceback.print_exc()
        return False
    
    # Test 3: Functional test
    print("\n3. Testing functional operations...")
    try:
        from mysite.interpreter.process import set_environment_variables
        set_environment_variables()
        print("βœ… Environment variables set")
        
        # Test folder creation simulation
        test_folder = f"test_{int(time.time())}"
        test_path = os.path.join(original_base_path, test_folder)
        os.makedirs(test_path, exist_ok=True)
        
        # Test file creation
        test_file = os.path.join(test_path, "prompt")
        with open(test_file, 'w') as f:
            f.write("Test prompt content")
        
        print(f"βœ… Test folder and file created: {test_path}")
        
        # Cleanup
        import shutil
        shutil.rmtree(test_path)
        print("βœ… Cleanup completed")
        
    except Exception as e:
        print(f"❌ Functional test failed: {e}")
        return False
    
    # Test 4: Configuration summary
    print("\n=== Configuration Summary ===")
    print(f"βœ… Base path: {original_base_path}")
    print(f"βœ… Environment type: {process_robust.get_environment_type()}")
    print(f"βœ… Path exists: {os.path.exists(original_base_path)}")
    print(f"βœ… Path writable: {os.access(original_base_path, os.W_OK)}")
    
    # Test 5: Environment variables
    print("\n=== Environment Variables ===")
    env_vars = ['INTERPRETER_BASE_PATH', 'OPENAI_API_KEY', 'MODEL_NAME']
    for var in env_vars:
        value = os.getenv(var, 'Not set')
        status = "βœ…" if value != 'Not set' else "⚠️"
        print(f"{status} {var}: {value[:20]}{'...' if len(value) > 20 else ''}")
    
    print("\n=== Verification Complete ===")
    print("βœ… All tests passed - process.py is working correctly")
    print(f"βœ… System ready for use with base path: {original_base_path}")
    
    return True

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