-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
53 lines (46 loc) · 1.65 KB
/
run.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
import requests
import os
import subprocess
import threading
import time
class run_api:
def setup(self):
os.environ["PYTHONUNBUFFERED"] = "1"
node = subprocess.Popen(
["node", f"{os.getcwd()}/rest_engine/dist/src/server.js"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
bufsize=1,
)
threading.Thread(target=self.read_output, args=(node, "Neon")).start()
python = subprocess.Popen(
["python", f"{os.getcwd()}/astra/src/main.py"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
bufsize=1,
)
threading.Thread(target=self.read_output, args=(python, "Astra")).start()
while True:
try:
connection = requests.get("http://localhost:3000/app/changelist")
if connection.status_code == 200:
break
except:
time.sleep(0.1)
finally:
time.sleep(3)
rust = subprocess.Popen(
[f"{os.getcwd()}/data_engine/bin/data_engine.exe"],
stdin=subprocess.PIPE,
)
rust.stdin.write(b"730")
def read_output(self, process, process_name):
for line in iter(process.stdout.readline, b""):
if line:
print(f"[{process_name} I/O] {line.strip()}", flush=True)
for line in iter(process.stderr.readline, b""):
if line:
print(f"[{process_name} Error] {line.strip()}", flush=True)
run_api().setup()