-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathboot_manager.py
38 lines (36 loc) · 1.06 KB
/
boot_manager.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
import os
import subprocess
import sys
import time
if sys.platform == "win32":
cmd = "python main.py"
else:
cmd = "exec python3.9 main.py"
p = subprocess.Popen(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
while True:
res = subprocess.run(
"git pull origin main --dry-run".split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)
if "main.py" in res.stdout:
p.kill()
res = subprocess.run(
"git pull origin main".split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)
p = subprocess.Popen(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
elif "origin/" in res.stdout:
subprocess.run("git pull origin main".split(), stdout=subprocess.DEVNULL)
elif os.path.exists("./reboot"):
os.remove("./reboot")
p.kill()
p = subprocess.Popen(cmd, shell=True)
elif os.path.exists("./shutdown"):
os.remove("./shutdown")
p.kill()
break
time.sleep(10)