-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlauncher.py
More file actions
85 lines (73 loc) · 2.45 KB
/
Copy pathlauncher.py
File metadata and controls
85 lines (73 loc) · 2.45 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
77
78
79
80
81
82
83
84
"""
DBO Universal Translation Tool - Electron Launcher
This script installs dependencies (if needed) and launches the Electron app.
"""
import subprocess
import sys
import os
from pathlib import Path
def check_node_installed():
"""Check if Node.js is installed"""
try:
subprocess.run(['node', '--version'], capture_output=True, check=True, shell=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def check_npm_installed():
"""Check if npm is installed"""
try:
subprocess.run(['npm', '--version'], capture_output=True, check=True, shell=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def install_dependencies():
"""Install npm dependencies"""
print("Installing dependencies...")
try:
subprocess.run(['npm', 'install'], check=True, shell=True)
print("✓ Dependencies installed successfully!\n")
except subprocess.CalledProcessError as e:
print(f"✗ Error installing dependencies: {e}")
sys.exit(1)
def launch_electron():
"""Launch the Electron app"""
print("Launching Electron app...")
try:
subprocess.run(['npm', 'start'], check=True, shell=True)
except subprocess.CalledProcessError as e:
print(f"✗ Error launching Electron: {e}")
sys.exit(1)
def main():
print("=" * 50)
print("DBO Universal Translation Tool - Electron Launcher")
print("=" * 50)
print()
# Check if Node.js is installed
if not check_node_installed():
print("✗ Node.js is not installed!")
print(" Please install Node.js from: https://nodejs.org/")
sys.exit(1)
else:
print("✓ Node.js is installed")
# Check if npm is installed
if not check_npm_installed():
print("✗ npm is not installed!")
print(" npm should come with Node.js installation")
sys.exit(1)
else:
print("✓ npm is installed")
# Check if node_modules exists
node_modules_path = Path(__file__).parent / 'node_modules'
if not node_modules_path.exists():
print("\n⚠ Dependencies not found. Installing...")
install_dependencies()
else:
print("✓ Dependencies found")
print()
launch_electron()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nProgram interrupted by user.")
sys.exit(0)