-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute_planner.py
More file actions
executable file
·76 lines (65 loc) · 2.42 KB
/
route_planner.py
File metadata and controls
executable file
·76 lines (65 loc) · 2.42 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
71
72
73
74
75
76
#!/usr/bin/env python3
"""
Route Planner Cross-Platform Launcher
=====================================
This script provides cross-platform compatibility and path detection.
Use this for:
- Cross-platform execution: python route_planner.py
- Systems where main.py might have issues
- Advanced users who need platform detection
Most users should use the installed 'route-planner' command instead.
"""
import os
import platform
import subprocess
import sys
from pathlib import Path
# Add the current directory to sys.path if needed
current_dir = Path(__file__).parent.absolute()
if str(current_dir) not in sys.path:
sys.path.insert(0, str(current_dir))
try:
# Try to import from the package
from route_planner.paths import get_app_dir, get_platform_script
except ImportError:
# If that fails, try to import directly
sys.path.insert(0, str(current_dir / 'route_planner'))
try:
from paths import get_app_dir, get_platform_script
except ImportError:
# If all else fails, define the functions directly
def get_app_dir():
return Path(__file__).parent.absolute()
def get_platform_script(script_name):
app_dir = get_app_dir()
if platform.system() == "Windows":
return app_dir / f"{script_name}.bat"
else:
return app_dir / f"{script_name}.sh"
def main():
"""Main entry point that delegates to platform-specific scripts."""
project_root = get_app_dir()
# Determine which script to run based on platform
script_path = get_platform_script('run_route_planner')
if not script_path.exists():
print(f"❌ {script_path.name} not found")
sys.exit(1)
# Execute the appropriate script
try:
# Pass any command line arguments to the script
if platform.system() == "Windows":
process = subprocess.Popen([str(script_path)] + sys.argv[1:],
cwd=str(project_root), shell=True)
else:
process = subprocess.Popen([str(script_path)] + sys.argv[1:],
cwd=str(project_root))
process.wait()
sys.exit(process.returncode)
except KeyboardInterrupt:
print("\n🛑 Application interrupted by user")
sys.exit(0)
except Exception as e:
print(f"❌ Error running application: {e}")
sys.exit(1)
if __name__ == "__main__":
main()