-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_import_tool.py
More file actions
66 lines (54 loc) · 2.21 KB
/
Copy pathrun_import_tool.py
File metadata and controls
66 lines (54 loc) · 2.21 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
#!/usr/bin/env python3
"""
MushLog Import Tool Launcher Script
Launches the MushLog Import Tool with proper environment setup.
"""
import sys
import os
# Add the apps directory to the Python path
script_dir = os.path.dirname(os.path.abspath(__file__))
apps_dir = os.path.join(script_dir, 'apps')
if os.path.exists(apps_dir):
sys.path.insert(0, apps_dir)
# Add the current directory to the Python path for resources
sys.path.insert(0, script_dir)
# Set up resource path for the launcher
def resource_path(relative_path):
"""Get absolute path to resource (handles dev, onedir, and onefile modes)"""
# Try multiple possible locations for bundled resources
possible_paths = []
# For Nuitka onefile mode
if hasattr(sys, '_MEIPASS'):
possible_paths.append(os.path.join(sys._MEIPASS, relative_path))
# For Nuitka onedir mode or PyInstaller
if getattr(sys, 'frozen', False):
base_path = os.path.dirname(os.path.abspath(sys.argv[0]))
possible_paths.append(os.path.join(base_path, relative_path))
# For development mode - check multiple locations
script_dir = os.path.dirname(os.path.abspath(__file__))
# Try resources directory first (for distribution package)
resources_dir = os.path.join(script_dir, "resources")
possible_paths.append(os.path.join(resources_dir, relative_path))
# Try current directory (original behavior)
possible_paths.append(os.path.join(script_dir, relative_path))
# Try each possible path
for path in possible_paths:
if os.path.exists(path):
return path
# If not found, return the first possible path (for debugging)
return possible_paths[0] if possible_paths else relative_path
if __name__ == "__main__":
try:
# Import and run the import tool application
from apps.import_tool import main
main()
except ImportError as e:
print(f"Error importing Import Tool: {e}")
print("Please ensure all dependencies are installed:")
print(" pip install -r requirements.txt")
sys.exit(1)
except Exception as e:
print(f"Error running Import Tool: {e}")
import traceback
traceback.print_exc()
sys.exit(1)