mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Verify Network.json is valid json before loading
This commit is contained in:
parent
e726ac754b
commit
2ee3510f06
@ -40,7 +40,7 @@ def clearPriorSettings(interfaceA, interfaceB):
|
||||
|
||||
def refreshShapers():
|
||||
tcpOverheadFactor = 1.09
|
||||
|
||||
|
||||
# Load Subscriber Circuits & Devices
|
||||
subscriberCircuits = []
|
||||
knownCircuitIDs = []
|
||||
@ -127,6 +127,15 @@ def refreshShapers():
|
||||
}
|
||||
subscriberCircuits.append(thisCircuit)
|
||||
|
||||
#Verify Network.json is valid json
|
||||
with open('network.json') as file:
|
||||
try:
|
||||
temporaryVariable = json.load(file) # put JSON-data to a variable
|
||||
except json.decoder.JSONDecodeError:
|
||||
print("network.json is an invalid JSON file") # in case json is invalid
|
||||
else:
|
||||
print("network.json appears to be a valid JSON file") # in case json is valid
|
||||
|
||||
#Load network heirarchy
|
||||
with open('network.json', 'r') as j:
|
||||
network = json.loads(j.read())
|
||||
|
Loading…
Reference in New Issue
Block a user