VirtualMailManager/cli/config.py
branchv0.6.x
changeset 322 94bd10e237e5
parent 320 011066435e6f
child 341 6709d0faf2f5
equal deleted inserted replaced
321:883d5cd66498 322:94bd10e237e5
    55                                                   VMM_TOO_MANY_FAILURES)
    55                                                   VMM_TOO_MANY_FAILURES)
    56                     else:
    56                     else:
    57                         break
    57                         break
    58             print
    58             print
    59         if self._modified:
    59         if self._modified:
    60             self.__save_changes()
    60             self._save_changes()
    61 
    61 
    62     def set(self, option, value):
    62     def set(self, option, value):
    63         """Set the value of an option.
    63         """Set the value of an option.
    64 
    64 
    65         If the new `value` has been set, the configuration file will be
    65         If the new `value` has been set, the configuration file will be
    79         if val == old_val:
    79         if val == old_val:
    80             return
    80             return
    81         if not RawConfigParser.has_section(self, section):
    81         if not RawConfigParser.has_section(self, section):
    82             self.add_section(section)
    82             self.add_section(section)
    83         RawConfigParser.set(self, section, option_, val)
    83         RawConfigParser.set(self, section, option_, val)
    84         self.__save_changes()
    84         self._save_changes()
    85 
    85 
    86     def __save_changes(self):
    86     def _save_changes(self):
    87         """Writes changes to the configuration file."""
    87         """Writes changes to the configuration file."""
    88         copy2(self._cfg_filename, self._cfg_filename + '.bak')
    88         copy2(self._cfg_filename, self._cfg_filename + '.bak')
    89         self._cfg_file = open(self._cfg_filename, 'w')
    89         self._cfg_file = open(self._cfg_filename, 'w')
    90         self.write(self._cfg_file)
    90         self.write(self._cfg_file)
    91         self._cfg_file.close()
    91         self._cfg_file.close()