-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_destress_headless.py
74 lines (66 loc) · 4.03 KB
/
run_destress_headless.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
63
64
65
66
67
68
69
70
71
72
73
74
import os
import os.path as p
import argpass
from subprocess import call
##############################################################################
# get inputs
def read_inputs():
## create an argpass parser, read config file,
parser = argpass.ArgumentParser()
parser.add_argument("--i")
args = parser.parse_args()
inputPath=args.i
return inputPath
##############################################################################
def main():
inputPath = read_inputs()
if not p.isabs(inputPath):
ascii_splash("ERROR")
print("Input Path must be Absolute!")
return
ascii_splash("DESTRESS")
deStressDir = os.getcwd()
dependanciesDir = p.join(deStressDir,"dependencies_for_de-stress")
# Try the first command
result = call(["docker", "run", "-it", "--rm",
"--env-file", ".env-headless",
"-v", f"{dependanciesDir}:/dependencies_for_de-stress",
"-v", f"{inputPath}:/input_path",
"de-stress-big-structure:latest",
"poetry", "run", "headless_destress", "/input_path"])
# If the first command fails, try the second command
if result != 0:
print("First command failed, trying de-stress_big-structure...")
result = call(["docker", "run", "-it", "--rm",
"--env-file", ".env-headless",
"-v", f"{dependanciesDir}:/dependencies_for_de-stress",
"-v", f"{inputPath}:/input_path",
"de-stress_big-structure:latest",
"poetry", "run", "headless_destress", "/input_path"])
##############################################################################
def ascii_splash(id):
splashDict = {"DESTRESS":
"""
██████╗ ███████╗ ███████╗████████╗██████╗ ███████╗███████╗███████╗
██╔══██╗██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔════╝██╔════╝██╔════╝
██║ ██║█████╗█████╗███████╗ ██║ ██████╔╝█████╗ ███████╗███████╗
██║ ██║██╔══╝╚════╝╚════██║ ██║ ██╔══██╗██╔══╝ ╚════██║╚════██║
██████╔╝███████╗ ███████║ ██║ ██║ ██║███████╗███████║███████║
╚═════╝ ╚══════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
""",
"ERROR":
"""
▓█████ ██▀███ ██▀███ ▒█████ ██▀███
▓█ ▀ ▓██ ▒ ██▒▓██ ▒ ██▒▒██▒ ██▒▓██ ▒ ██▒
▒███ ▓██ ░▄█ ▒▓██ ░▄█ ▒▒██░ ██▒▓██ ░▄█ ▒
▒▓█ ▄ ▒██▀▀█▄ ▒██▀▀█▄ ▒██ ██░▒██▀▀█▄
░▒████▒░██▓ ▒██▒░██▓ ▒██▒░ ████▓▒░░██▓ ▒██▒
░░ ▒░ ░░ ▒▓ ░▒▓░░ ▒▓ ░▒▓░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░
░ ░ ░ ░▒ ░ ▒░ ░▒ ░ ▒░ ░ ▒ ▒░ ░▒ ░ ▒░
░ ░░ ░ ░░ ░ ░ ░ ░ ▒ ░░ ░
░ ░ ░ ░ ░ ░ ░
"""
}
print(splashDict[id])
##############################################################################
main()