-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
62 lines (48 loc) · 1.4 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
54
55
56
57
58
59
60
61
62
from sys import argv
from utils import run_script, base_path, host, setenv
from time import sleep
import webbrowser as browser
from multiprocessing import Pool
global procs
procs = []
def open_page():
sleep(3)
browser.open(host["url"])
def config_update(mode="development"):
fpath = base_path.joinpath(f"conf/{mode}.yml")
file = base_path.joinpath("_config.yml")
if mode == "development":
file.open("w").write(
fpath.open().read().replace(
"<URL>", host["url"]
)
)
elif mode == "production":
file.open("w").write(fpath.open().read())
def run(proc):
proc()
class Main:
opts = ["serve", "build", "update"]
@staticmethod
def update():
config_update(mode="production")
setenv("allow-push", "true")
run_script("push")
@staticmethod
def serve():
config_update(mode="development")
run_script("make", "serve")
@staticmethod
def build():
config_update(mode="development")
run_script("make", "build")
if __name__ == "__main__":
config_update(mode="development")
opt = argv[1] if len(argv) > 1 else None
if opt in Main.opts:
procs.append(getattr(Main, opt))
try:
with Pool(len(procs)) as p:
p.map(run, procs)
except KeyboardInterrupt as err:
print(err)