VirtualMailManager/config.py
branchv0.6.x
changeset 481 90d69ae4f40d
parent 458 4ff0fa3ba0fa
child 496 17f2c5b5098e
equal deleted inserted replaced
480:099de308fd98 481:90d69ae4f40d
   358         """Loads the configuration, read only.
   358         """Loads the configuration, read only.
   359 
   359 
   360         Raises a ConfigError if the configuration syntax is
   360         Raises a ConfigError if the configuration syntax is
   361         invalid.
   361         invalid.
   362         """
   362         """
       
   363         self._cfg_file = open(self._cfg_filename, 'r')
   363         try:
   364         try:
   364             self._cfg_file = open(self._cfg_filename, 'r')
       
   365             self.readfp(self._cfg_file)
   365             self.readfp(self._cfg_file)
   366         except (MissingSectionHeaderError, ParsingError), err:
   366         except (MissingSectionHeaderError, ParsingError), err:
   367             raise ConfigError(str(err), CONF_ERROR)
   367             raise ConfigError(str(err), CONF_ERROR)
   368         finally:
   368         self._cfg_file.close()
   369             if self._cfg_file and not self._cfg_file.closed:
       
   370                 self._cfg_file.close()
       
   371 
   369 
   372     def check(self):
   370     def check(self):
   373         """Performs a configuration check.
   371         """Performs a configuration check.
   374 
   372 
   375         Raises a ConfigError if settings w/o a default value are missed.
   373         Raises a ConfigError if settings w/o a default value are missed.