forked from openshift-psap/topsail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_toolbox.py
executable file
·39 lines (31 loc) · 992 Bytes
/
run_toolbox.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
#!/usr/bin/env python
import sys
try:
import fire
except ModuleNotFoundError:
print("The toolbox requires the Python `fire` package, see requirements.txt for a full list of requirements")
sys.exit(1)
import projects.core.library.ansible_toolbox
def main(no_exit=False):
# Print help rather than opening a pager
fire.core.Display = lambda lines, out: print(*lines, file=out)
# Launch CLI, get a runnable
runnable = None
try:
runnable = fire.Fire(projects.core.library.ansible_toolbox.Toolbox())
except fire.core.FireExit:
if not no_exit:
raise
# Run the actual workload
try:
if hasattr(runnable, "_run"):
runnable._run()
else:
# CLI didn't resolve completely - either by lack of arguments
# or use of `--help`. This is okay.
pass
except SystemExit as e:
if not no_exit:
sys.exit(e.code)
if __name__ == "__main__":
main()