import types
+class ConfigurationException(Exception): pass
+
class PLCConfiguration:
"""
Configuration file store. Optionally instantiate with a file path
fileobj.close()
+ def verify(self, default, read):
+ """ Confirm that the existing configuration is consistent according to
+ the checks below.
+
+ It looks for filled-in values in the order of, local object (self),
+ followed by cread (read values), and finally default values.
+
+ Arguments:
+
+ None
+
+ Returns:
+
+ None. If an exception is found, ConfigurationException is raised.
+
+ """
+
+ (category,maint_user) = self.get('plc_api', 'maintenance_user')
+ if maint_user == None:
+ (category, maint_user) = read.get('plc_api', 'maintenance_user')
+ if maint_user == None:
+ (category,maint_user) = default.get('plc_api', 'maintenance_user')
+ if maint_user == None:
+ raise ConfigurationException("Cannot find PLC_API_MAINTENANCE_USER")
+
+ (category,root_user) = self.get('plc', 'root_user')
+ if root_user == None:
+ (category,root_user) = read.get('plc', 'root_user')
+ if root_user == None:
+ root_user = default.get('plc', 'root_user')
+ if root_user == None:
+ raise ConfigurationException("Cannot find PLC_ROOT_USER")
+
+ muser= maint_user['value']
+ ruser= root_user['value']
+
+ if muser == ruser:
+ raise ConfigurationException("The Maintenance Account email address cannot be the same as the Root User email address")
+ return
+
def get(self, category_id, variable_id):
"""