modbus/web_settings.py
changeset 2690 4de6a587f7f9
parent 2686 703ebf57508a
child 2691 6e4a95621080
equal deleted inserted replaced
2689:7f67a7f6bfcc 2690:4de6a587f7f9
   226 
   226 
   227         # Add the addr_type and node_type to the data that will be saved to file
   227         # Add the addr_type and node_type to the data that will be saved to file
   228         # This allows us to confirm the saved data contains the correct addr_type
   228         # This allows us to confirm the saved data contains the correct addr_type
   229         # when loading from file
   229         # when loading from file
   230         save_info = {}
   230         save_info = {}
   231         save_info["addr_type"] = ["addr_type"]
   231         save_info["addr_type"] = WebNode_entry["addr_type"]
   232         save_info["node_type"] = WebNode_entry["node_type"]
   232         save_info["node_type"] = WebNode_entry["node_type"]
   233         save_info["config"   ] = newConfig
   233         save_info["config"   ] = newConfig
   234         
   234         
   235         filename = WebNode_entry["filename"]
   235         filename = WebNode_entry["filename"]
   236 
   236 
   260     addr_type of the WebNode_id), then return None
   260     addr_type of the WebNode_id), then return None
   261     """
   261     """
   262     filename = _WebNodeList[WebNode_id]["filename"]
   262     filename = _WebNodeList[WebNode_id]["filename"]
   263     try:
   263     try:
   264         #if os.path.isfile(filename):
   264         #if os.path.isfile(filename):
   265         save_info = json.load(open(filename))
   265         save_info = json.load(open(os.path.realpath(filename)))
   266     except Exception:    
   266     except Exception:    
   267         return None
   267         return None
   268 
   268 
   269     if save_info["addr_type"] != _WebNodeList[WebNode_id]["addr_type"]:
   269     if save_info["addr_type"] != _WebNodeList[WebNode_id]["addr_type"]:
   270         return None
   270         return None