From dbebef95b8bd621a60e24a236d8f90df68bf354a Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 31 Oct 2017 21:02:16 +0000 Subject: [PATCH 1/2] Allow integer indexed arrays in JSON structure --- main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 72a83cb..401753a 100644 --- a/main.py +++ b/main.py @@ -79,9 +79,12 @@ def jsonVal(url, struct): try: for i in struct.split('.'): - dataDict = dataDict[i] + if i.isdigit(): + dataDict = dataDict[int(i)] + else: + dataDict = dataDict[i] return dataDict - except KeyError: + except: print('Error: Invalid structure: ' + struct) print(dataDict) raise From 2d399044da39a5f65b2b761ec12ce4db70966382 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 31 Oct 2017 21:02:57 +0000 Subject: [PATCH 2/2] Print useful error message when exiting with no output --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 401753a..bfb655c 100644 --- a/main.py +++ b/main.py @@ -139,6 +139,7 @@ if __name__ == '__main__': try: curr_value = jsonVal(config[service].get('url'), config[service].get('structure')) except: + print('Error: Could not get current value for ' + service) exit(1) print('Writing Initial value for ' + service + ': ' + curr_value) config[service]['current_value'] = curr_value