Repository navigation
Expand file tree
/
Copy pathcheck_app_structure.py
More file actions
70 lines (57 loc) · 2.4 KB
/
Copy pathcheck_app_structure.py
File metadata and controls
70 lines (57 loc) · 2.4 KB
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
"""
This script checks your application structure to help diagnose import issues.
Save this file in your project root directory (analytics1) and run it with:
python check_app_structure.py
"""
import os
import sys
def check_file_exists(path):
exists = os.path.exists(path)
print(f"Checking {path}: {'EXISTS' if exists else 'MISSING'}")
return exists
def print_directory_tree(startpath, level=0):
for root, dirs, files in os.walk(startpath):
if '__pycache__' in root or '.git' in root or 'venv' in root:
continue
relative_path = os.path.relpath(root, startpath)
if relative_path == '.':
print(f"Directory structure of {os.path.abspath(startpath)}:")
indent = ' ' * 4 * (level if relative_path == '.' else relative_path.count(os.sep))
folder_name = os.path.basename(root) if relative_path != '.' else os.path.basename(os.path.abspath(startpath))
print(f"{indent}{folder_name}/")
sub_indent = ' ' * 4 * (level + 1 if relative_path == '.' else relative_path.count(os.sep) + 1)
for f in sorted(files):
if f.startswith('.') or f.endswith('.pyc'):
continue
print(f"{sub_indent}{f}")
def main():
print("\n=== Python Path ===")
print(f"sys.path: {sys.path}")
print("\n=== Current Working Directory ===")
print(f"cwd: {os.getcwd()}")
print("\n=== Application Structure ===")
print_directory_tree('.')
print("\n=== Critical Files ===")
check_file_exists("app/core/supabase_service.py")
check_file_exists("app/core/__init__.py")
check_file_exists("app/api/routes/inventory.py")
check_file_exists("app/api/routes/__init__.py")
check_file_exists("app/api/__init__.py")
check_file_exists("app/__init__.py")
print("\n=== Files Content Check ===")
files_to_check = [
"app/core/supabase_service.py",
"app/api/routes/inventory.py",
"app/main.py"
]
for file_path in files_to_check:
if check_file_exists(file_path):
try:
with open(file_path, 'r') as f:
content = f.read()
first_line = content.split('\n')[0]
print(f"First line of {file_path}: {first_line}")
except Exception as e:
print(f"Error reading {file_path}: {e}")
if __name__ == "__main__":
main()