2022-06-15 10:43:29 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2022-06-17 15:13:16 +02:00
|
|
|
import sys
|
2022-06-15 10:43:29 +02:00
|
|
|
import json
|
2022-06-17 15:13:16 +02:00
|
|
|
import argparse
|
2022-06-15 10:43:29 +02:00
|
|
|
|
2022-06-17 15:13:16 +02:00
|
|
|
# Parse all arguments
|
|
|
|
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
2022-06-17 15:36:07 +02:00
|
|
|
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector file")
|
2022-06-17 15:13:16 +02:00
|
|
|
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
|
|
|
if len(sys.argv)==1:
|
|
|
|
parser.print_help(sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
args = parser.parse_args()
|
|
|
|
json_file = args.file
|
|
|
|
|
|
|
|
except argparse.ArgumentError as e:
|
|
|
|
print(str(e))
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
with open (json_file, 'r') as f:
|
2022-06-15 10:43:29 +02:00
|
|
|
body = json.load(f)
|
2022-06-17 15:13:16 +02:00
|
|
|
if args.pretty:
|
|
|
|
print(json.dumps(body, indent=4))
|
|
|
|
else:
|
2022-06-17 15:36:07 +02:00
|
|
|
print(json.dumps(body))
|