X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc_config.py;h=bbc2f5186a9717b9839f85360d0892caa469adef;hb=22584cd5928950d82106f43965add51da366cb49;hp=c9382d24510e854cc508a8676eff1196320f13e3;hpb=3d5b576cb47133841a4880c6648210363a431851;p=myplc.git diff --git a/plc_config.py b/plc_config.py index c9382d2..bbc2f51 100644 --- a/plc_config.py +++ b/plc_config.py @@ -20,6 +20,8 @@ import os import types +class ConfigurationException(Exception): pass + class PLCConfiguration: """ Configuration file store. Optionally instantiate with a file path @@ -235,6 +237,42 @@ class PLCConfiguration: 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. + + """ + + maint_user = self.get('plc_api', 'maintenance_user') + if maint_user == (None, None): + maint_user = read.get('plc_api', 'maintenance_user') + if maint_user == (None, None): + maint_user = default.get('plc_api', 'maintenance_user') + + root_user = self.get('plc', 'root_user') + if root_user == (None, None): + root_user = read.get('plc', 'root_user') + if root_user == (None, None): + root_user = default.get('plc', 'root_user') + + muser= maint_user[1]['value'] + ruser= root_user[1]['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): """