Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,44 @@
|
|
1 |
import os
|
2 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Add the current working directory to Python's module search path
|
5 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
6 |
-
|
7 |
if current_dir not in sys.path:
|
8 |
sys.path.insert(0, current_dir)
|
9 |
|
10 |
-
# Debugging:
|
11 |
print("DEBUG: sys.path =", sys.path)
|
12 |
-
|
13 |
-
|
14 |
-
print("DEBUG: Does 'routes' directory exist? ", os.path.exists(
|
15 |
-
print("DEBUG: Does 'auth.py' exist in 'routes'? ", os.path.exists(
|
16 |
|
17 |
# Import modules
|
18 |
try:
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
+
import shutil
|
4 |
+
import stat
|
5 |
+
|
6 |
+
# Clear Python cache directories
|
7 |
+
def clear_pycache():
|
8 |
+
print("DEBUG: Clearing Python cache...")
|
9 |
+
for root, dirs, files in os.walk("."):
|
10 |
+
for dir_name in dirs:
|
11 |
+
if dir_name == "__pycache__":
|
12 |
+
pycache_path = os.path.join(root, dir_name)
|
13 |
+
print(f"DEBUG: Removing {pycache_path}")
|
14 |
+
shutil.rmtree(pycache_path)
|
15 |
+
|
16 |
+
# Verify file permissions
|
17 |
+
def verify_permissions(file_path):
|
18 |
+
if os.path.exists(file_path):
|
19 |
+
# Check if the file is readable
|
20 |
+
if not os.access(file_path, os.R_OK):
|
21 |
+
print(f"DEBUG: Fixing permissions for {file_path}")
|
22 |
+
os.chmod(file_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
|
23 |
+
|
24 |
+
# Run cache clearing and permission verification
|
25 |
+
clear_pycache()
|
26 |
+
verify_permissions("routes/auth.py")
|
27 |
+
verify_permissions("routes/menu.py")
|
28 |
+
verify_permissions("routes/orders.py")
|
29 |
+
verify_permissions("utils/file_initializer.py")
|
30 |
|
31 |
# Add the current working directory to Python's module search path
|
32 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
33 |
if current_dir not in sys.path:
|
34 |
sys.path.insert(0, current_dir)
|
35 |
|
36 |
+
# Debugging: Verify paths
|
37 |
print("DEBUG: sys.path =", sys.path)
|
38 |
+
routes_dir = os.path.join(current_dir, "routes")
|
39 |
+
auth_file_path = os.path.join(routes_dir, "auth.py")
|
40 |
+
print("DEBUG: Does 'routes' directory exist? ", os.path.exists(routes_dir))
|
41 |
+
print("DEBUG: Does 'auth.py' exist in 'routes'? ", os.path.exists(auth_file_path))
|
42 |
|
43 |
# Import modules
|
44 |
try:
|