-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-interactive.py
More file actions
executable file
·46 lines (35 loc) · 1.01 KB
/
build-interactive.py
File metadata and controls
executable file
·46 lines (35 loc) · 1.01 KB
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
#!/usr/bin/python3
import os
import subprocess
import sys
from os.path import abspath, dirname, join
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.history import FileHistory
rootDir = dirname(abspath(__file__))
settingsDir = join(rootDir, "settings")
sys.path.insert(0, settingsDir)
from settings.build_common import prompt # noqa: E402
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,
)