From 449b490f233371fe28e9089a05982cd5634285d2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 27 Sep 2020 21:12:51 +0200 Subject: Implement MVP --- iot_barcode_scanner/config.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 iot_barcode_scanner/config.py (limited to 'iot_barcode_scanner/config.py') diff --git a/iot_barcode_scanner/config.py b/iot_barcode_scanner/config.py new file mode 100644 index 0000000..6b83393 --- /dev/null +++ b/iot_barcode_scanner/config.py @@ -0,0 +1,23 @@ + + +"""Module to read the Configuration File for the Service""" + + +import sys +import json +from iot_barcode_scanner.static import CONFIG_PATH + + +def get_config(): + """Read Config File and return it as Python Object""" + + try: + with open(CONFIG_PATH, "r") as config_file: + text = config_file.read() + except FileNotFoundError: + print("Config file does not exist.") + sys.exit(1) + + data = json.loads(text) + + return data -- cgit v1.2.3-70-g09d2