-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacro-mate.py
60 lines (48 loc) · 1.53 KB
/
macro-mate.py
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
import subprocess
import threading
import atexit
gui_process = None
cpp_process = None
python_process = None
def run_gui():
global gui_process
gui_process = subprocess.Popen(["dist/gui.exe"])
gui_process.wait()
def run_cpp():
global cpp_process
cpp_process = subprocess.Popen(["dist/server.exe"])
cpp_process.wait()
def run_python():
global python_process
python_process = subprocess.Popen(["dist/socket_pipe.exe"])
python_process.wait()
def cleanup():
global gui_process, cpp_process, python_process
# Terminate subprocesses if they are still running
if gui_process and gui_process.poll() is None:
gui_process.terminate()
cpp_process.terminate()
python_process.terminate()
if cpp_process and cpp_process.poll() is None:
gui_process.terminate()
cpp_process.terminate()
python_process.terminate()
if python_process and python_process.poll() is None:
gui_process.terminate()
cpp_process.terminate()
python_process.terminate()
if __name__ == "__main__":
# Register the cleanup function to be called at exit
atexit.register(cleanup)
# Create threads for each component
gui_thread = threading.Thread(target=run_gui)
cpp_thread = threading.Thread(target=run_cpp)
python_thread = threading.Thread(target=run_python)
# Start the threads
gui_thread.start()
cpp_thread.start()
python_thread.start()
# Wait for threads to finish
gui_thread.join()
cpp_thread.join()
python_thread.join()