Runtime: more robust loading of Wamp config, specially in case config file was corrupted. svghmi
authorEdouard Tisserant
Tue, 20 Jul 2021 10:52:25 +0200
branchsvghmi
changeset 3285 d6612579f1d4
parent 3284 55e69df85fe1
child 3286 5a135e635bfa
Runtime: more robust loading of Wamp config, specially in case config file was corrupted.
runtime/WampClient.py
--- a/runtime/WampClient.py	Tue Jul 20 09:43:35 2021 +0200
+++ b/runtime/WampClient.py	Tue Jul 20 10:52:25 2021 +0200
@@ -198,9 +198,15 @@
 def GetConfiguration():
     global lastKnownConfig
 
+    WampClientConf = None
+
     if os.path.exists(_WampConf):
-        WampClientConf = json.load(open(_WampConf))
-    else:
+        try: 
+            WampClientConf = json.load(open(_WampConf))
+        except ValueError:
+            pass
+
+    if WampClientConf is None:
         WampClientConf = defaultWampConfig.copy()
 
     for itemName in mandatoryConfigItems: