feat(groups): Launch specific checks from groups and services (#1204)

This commit is contained in:
Pepe Fagoaga
2022-06-16 13:27:25 +02:00
committed by GitHub
parent 8abcc5988d
commit f694a6d12a
16 changed files with 201 additions and 95 deletions

27
lib/utils/utils.py Normal file
View File

@@ -0,0 +1,27 @@
import json
from io import TextIOWrapper
from typing import Any
from lib.logger import logger
def open_file(input_file: str) -> TextIOWrapper:
try:
# First recover the available groups in groups.json
f = open(input_file)
except Exception as e:
logger.critical(f"{input_file}: {e.__class__.__name__}")
quit()
else:
return f
# Parse checks from file
def parse_json_file(input_file: TextIOWrapper) -> Any:
try:
json_file = json.load(input_file)
except Exception as e:
logger.critical(f"{input_file.name}: {e.__class__.__name__}")
quit()
else:
return json_file