isp-maintenance/mgrctl/utils/helpers.py

24 lines
606 B
Python

import json
import sys
import click
def parse_json_file(file_path: str) -> dict:
"""
Function read json file as usual config.json then parse it to python dict
Args:
config_file_path (str): path to config file
Returns:
dict: contains parse json content
"""
try:
with open(file_path, 'r') as f:
return json.load(f)
except Exception as error:
click.echo(error)
click.echo("Required: /opt/ispsystem/PLATFORM_TYPE/config.json")
click.echo("Note: don't forget to mount this file into the container")
sys.exit(1)