-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·88 lines (76 loc) · 2.4 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·88 lines (76 loc) · 2.4 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
import os
import subprocess
from pathlib import PosixPath
TARGET_RELEASE = "v1.2.0"
WORKSPACE_DIR = PosixPath("/workspace")
def download_release():
# Download the binaries
for binary in ["cluebotng", "create_ann", "create_bayes_db", "print_bayes_db"]:
target_path = WORKSPACE_DIR / binary
if not target_path.is_file():
subprocess.run(
[
"curl",
"--silent",
"--show-error",
"--fail",
"-L",
"-o",
target_path.as_posix(),
f"https://github.com/cluebotng/core/releases/download/{TARGET_RELEASE}/{binary}",
],
check=True,
)
target_path.chmod(0x555)
# Download the databases
(WORKSPACE_DIR / "data").mkdir(parents=True, exist_ok=True)
for database in ["main_ann.fann", "bayes.db", "two_bayes.db"]:
target_path = WORKSPACE_DIR / "data" / database
if not target_path.is_file():
subprocess.run(
[
"curl",
"--silent",
"--show-error",
"--fail",
"-L",
"-o",
target_path.as_posix(),
f"https://github.com/cluebotng/core/releases/download/{TARGET_RELEASE}/{database}",
],
check=True,
)
# Download the config
if not (WORKSPACE_DIR / "conf").is_dir():
subprocess.run(
[
"curl",
"--silent",
"--show-error",
"--fail",
"-L",
"-o",
"/tmp/conf.tar.gz",
f"https://github.com/cluebotng/core/releases/download/{TARGET_RELEASE}/conf.tar.gz",
],
check=True,
)
subprocess.run(
[
"tar",
"-C",
WORKSPACE_DIR.as_posix(),
"-xf",
"/tmp/conf.tar.gz",
],
check=True,
)
os.remove("/tmp/conf.tar.gz")
def main():
if not WORKSPACE_DIR.is_dir():
print(f"Skipping setup, workspace does not exist: {WORKSPACE_DIR}")
return
download_release()
if __name__ == "__main__":
main()