forked from agiresearch/AIOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec.py
More file actions
42 lines (30 loc) · 864 Bytes
/
exec.py
File metadata and controls
42 lines (30 loc) · 864 Bytes
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
import subprocess
import os
import time
from _exec import start_server, stop_server
import webbrowser
import sys
sys.path.append(os.getcwd())
print(sys.path[-1])
# def run_exec():
# # Run the _exec.py Python script asynchronously
# subprocess.Popen(['python', '_exec.py'])
def run_npm(open: bool=False):
# Change directory to the 'web' subdirectory
os.chdir('web')
# Run npm run dev asynchronously
if "node_modules" not in os.listdir():
install_process = subprocess.Popen(['npm', 'install'])
install_process.wait()
subprocess.Popen(['npm', 'run', 'dev'])
if open:
time.sleep(5)
webbrowser.open_new_tab("http://localhost:3000")
if __name__ == "__main__":
start_server()
run_npm(True)
try:
while True:
time.sleep(1)
finally:
stop_server()