-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_fvoas_electron.py
More file actions
executable file
·145 lines (123 loc) · 4.35 KB
/
run_fvoas_electron.py
File metadata and controls
executable file
·145 lines (123 loc) · 4.35 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python3
"""
FVOAS Electron Launcher
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Launch FVOAS as Electron desktop app (no browser)
Classification: SECRET
Device: 9 (Audio) | Layer: 3 | Clearance: 0x03030303
Usage:
python run_fvoas_electron.py
"""
import sys
import subprocess
import logging
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def check_electron_installed():
"""Check if Electron is installed."""
try:
result = subprocess.run(
['electron', '--version'],
capture_output=True,
timeout=5
)
return result.returncode == 0
except (FileNotFoundError, subprocess.TimeoutExpired):
return False
def install_electron_dependencies():
"""Install Electron dependencies if needed."""
electron_dir = Path(__file__).parent / "electron_app"
package_json = electron_dir / "package.json"
if not package_json.exists():
logger.error(f"package.json not found at {package_json}")
return False
logger.info("Installing Electron dependencies...")
try:
subprocess.run(
['npm', 'install'],
cwd=electron_dir,
check=True
)
logger.info("Electron dependencies installed successfully")
return True
except subprocess.CalledProcessError as e:
logger.error(f"Failed to install dependencies: {e}")
return False
except FileNotFoundError:
logger.error("npm not found. Please install Node.js and npm")
return False
def launch_electron():
"""Launch Electron app."""
electron_dir = Path(__file__).parent / "electron_app"
main_js = electron_dir / "main.js"
if not main_js.exists():
logger.error(f"main.js not found at {main_js}")
return False
# Ensure logo exists in electron_app/assets
assets_dir = electron_dir / "assets"
assets_dir.mkdir(exist_ok=True)
logo_src = Path(__file__).parent / "assets" / "fvoas_logo.svg"
logo_dst = assets_dir / "fvoas_logo.svg"
if logo_src.exists() and not logo_dst.exists():
import shutil
shutil.copy(logo_src, logo_dst)
logger.info("Copied logo to Electron app assets")
# Check if node_modules exists
node_modules = electron_dir / "node_modules"
if not node_modules.exists():
logger.info("Electron dependencies not found, installing...")
if not install_electron_dependencies():
return False
# Check if Electron is installed
if not check_electron_installed():
logger.info("Electron not found in PATH, installing locally...")
if not install_electron_dependencies():
return False
logger.info("Launching FVOAS Electron app...")
print("=" * 80)
print("FVOAS Voice Anonymization - Electron Desktop App")
print("=" * 80)
print("\n⚠️ Compliance Notice:")
print(" This system is COMPLIANT with federal specifications")
print(" but NOT AUDITED/CERTIFIED.")
print("\n" + "=" * 80 + "\n")
try:
# Try using electron command
subprocess.run(
['electron', str(electron_dir)],
cwd=electron_dir,
check=True
)
return True
except FileNotFoundError:
# Try using npx electron
try:
subprocess.run(
['npx', 'electron', str(electron_dir)],
cwd=electron_dir,
check=True
)
return True
except FileNotFoundError:
logger.error("Electron not found. Please install:")
logger.error(" npm install -g electron")
logger.error(" or")
logger.error(" cd electron_app && npm install")
return False
except subprocess.CalledProcessError as e:
logger.error(f"Failed to launch Electron: {e}")
return False
def main():
"""Main entry point."""
if launch_electron():
sys.exit(0)
else:
logger.error("Failed to launch Electron app")
logger.info("Fallback: Use web interface with --web flag")
sys.exit(1)
if __name__ == '__main__':
main()