-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-interactive.py
executable file
·48 lines (37 loc) · 1.02 KB
/
build-interactive.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
#!/usr/bin/python3
import sys
import os
from os.path import dirname, join, abspath, isdir, isfile
import subprocess
from prompt_toolkit.history import FileHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
rootDir = dirname(abspath(__file__))
settingsDir = join(rootDir, "settings")
sys.path.insert(0, settingsDir)
from settings.build_common import (
prompt,
)
homeDir = os.getenv("HOME")
if not homeDir:
raise ValueError("HOME is not set")
confDir = join(homeDir, ".starcal-server", "cli")
hostHistPath = join(confDir, "host-history")
os.makedirs(confDir, exist_ok=True)
def getHostName() -> str:
while True:
hostName = prompt(
"Host name: ",
history=FileHistory(hostHistPath),
auto_suggest=AutoSuggestFromHistory(),
)
if hostName:
return hostName
raise ValueError("host name is not given")
hostName = getHostName()
print()
env = dict(os.environ)
env["STARCAL_HOST"] = hostName
exit_code = subprocess.call(
["python3", "settings/build.py", "--interactive"] + sys.argv[1:],
env=env,
)