-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (38 loc) · 1.16 KB
/
main.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
import sys
import argparse
import os
if __name__ == "__main__":
__version__ = "2.0.2"
__author__ = "https://github.com/northpowered"
ap = argparse.ArgumentParser()
ap.add_argument(
"-c", "--config", required=True, help="Path to configuration yaml file"
)
ap.add_argument(
"-v",
"--verbose",
required=False,
help="Logging level",
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
)
ap.add_argument(
"-l", "--log-dest", required=False, help="Logging path {stdout,FILE}"
)
ap.add_argument("--version", action="version", version=__version__)
args = vars(ap.parse_args())
log_level = args.get("verbose")
log_dest = args.get("log_dest")
if not log_level:
log_level = os.getenv("SSLA_LL", "INFO")
if not log_dest:
log_dest = os.getenv("SSLA_LD", "stdout")
try:
from sla import SLAConfig
SLAConfig.load(args.get("config"))
from sla.sla import Sla
sla = Sla(
config_file=args.get("config"), log_level=log_level, log_dest=log_dest
)
sla.start()
except KeyboardInterrupt:
sys.exit()