-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_system.py
More file actions
46 lines (34 loc) · 1.09 KB
/
run_system.py
File metadata and controls
46 lines (34 loc) · 1.09 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
import subprocess
import time
import sys
import os
def main():
print("Starting Z-Manager System...")
# Ensure we are in the root directory
root_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(root_dir)
# Start Receiver (Tray App)
print("Launching Receiver (Z-Notify Client)...")
# Use Popen to run in parallel
receiver = subprocess.Popen(
[sys.executable, "z_notify_client/main.py"], cwd=root_dir
)
# Wait a bit to let receiver initialize
time.sleep(2)
# Start Sender (Main App)
print("Launching Sender (Main App)...")
sender = subprocess.Popen([sys.executable, "main.py"], cwd=root_dir)
print("Both processes launched.")
print("Press Ctrl+C to stop both.")
try:
# Wait for sender to close (Main Window)
sender.wait()
# Once sender closes, kill receiver
print("Main App closed. Stopping Receiver...")
receiver.terminate()
except KeyboardInterrupt:
print("Stopping...")
sender.terminate()
receiver.terminate()
if __name__ == "__main__":
main()