VirtualMailManager/config.py
branchv0.7.x
changeset 641 724ac0a4068d
parent 638 0de0b9e75c9f
child 642 4cd9d0a9f42f
equal deleted inserted replaced
640:ebacd11563b0 641:724ac0a4068d
   355         """Loads the configuration, read only.
   355         """Loads the configuration, read only.
   356 
   356 
   357         Raises a ConfigError if the configuration syntax is
   357         Raises a ConfigError if the configuration syntax is
   358         invalid.
   358         invalid.
   359         """
   359         """
   360         self._cfg_file = open(self._cfg_filename, 'r')
       
   361         try:
   360         try:
       
   361             self._cfg_file = open(self._cfg_filename, 'r')
   362             self.readfp(self._cfg_file)
   362             self.readfp(self._cfg_file)
   363         except (MissingSectionHeaderError, ParsingError), err:
   363         except (MissingSectionHeaderError, ParsingError), err:
   364             raise ConfigError(str(err), CONF_ERROR)
   364             raise ConfigError(str(err), CONF_ERROR)
   365         self._cfg_file.close()
   365         finally:
       
   366             if self._cfg_file and not self._cfg_file.closed:
       
   367                 self._cfg_file.close()
   366 
   368 
   367     def check(self):
   369     def check(self):
   368         """Performs a configuration check.
   370         """Performs a configuration check.
   369 
   371 
   370         Raises a ConfigError if settings w/o a default value are missed.
   372         Raises a ConfigError if settings w/o a default value are missed.