equal
deleted
inserted
replaced
318 'gid_mail': LCO(int, 8, self.getint), |
318 'gid_mail': LCO(int, 8, self.getint), |
319 'password_scheme': LCO(str, 'CRAM-MD5', self.get, |
319 'password_scheme': LCO(str, 'CRAM-MD5', self.get, |
320 self.known_scheme), |
320 self.known_scheme), |
321 'transport': LCO(str, 'dovecot:', self.get), |
321 'transport': LCO(str, 'dovecot:', self.get), |
322 }, |
322 }, |
323 'config': {'done': LCO(bool_t, False, self.get_boolean)} |
|
324 } |
323 } |
325 |
324 |
326 def load(self): |
325 def load(self): |
327 """Loads the configuration, read only. |
326 """Loads the configuration, read only. |
328 |
327 |
352 for option in options: |
351 for option in options: |
353 errmsg.write((u' %s\n') % option) |
352 errmsg.write((u' %s\n') % option) |
354 raise VMMConfigException(errmsg.getvalue(), ERR.CONF_ERROR) |
353 raise VMMConfigException(errmsg.getvalue(), ERR.CONF_ERROR) |
355 |
354 |
356 def getsections(self): |
355 def getsections(self): |
357 """Returns a generator object for all configurable sections.""" |
356 """Returns an iterator object for all configuration sections.""" |
358 return (s for s in self._cfg.iterkeys() if s != 'config') |
357 return self._cfg.iterkeys() |
359 |
358 |
360 def is_dir(self, path): |
359 def is_dir(self, path): |
361 """Checks if ``path`` is a directory. |
360 """Checks if ``path`` is a directory. |
362 |
361 |
363 Throws a `ConfigValueError` if ``path`` is not a directory. |
362 Throws a `ConfigValueError` if ``path`` is not a directory. |
407 """ |
406 """ |
408 input_fmt = _(u'Enter new value for option %(option)s \ |
407 input_fmt = _(u'Enter new value for option %(option)s \ |
409 [%(current_value)s]: ') |
408 [%(current_value)s]: ') |
410 failures = 0 |
409 failures = 0 |
411 |
410 |
412 # if config.done == false (default at 1st run), |
|
413 # then set changes true |
|
414 if not self.dget('config.done'): |
|
415 self._modified = True |
|
416 w_std(_(u'Using configuration file: %s\n') % self.__cfgFileName) |
411 w_std(_(u'Using configuration file: %s\n') % self.__cfgFileName) |
417 for s in sections: |
412 for s in sections: |
418 w_std(_(u'* Configuration section: ā%sā') % s ) |
413 w_std(_(u'* Configuration section: ā%sā') % s ) |
419 for opt, val in self.items(s): |
414 for opt, val in self.items(s): |
420 failures = 0 |
415 failures = 0 |
438 if self._modified: |
433 if self._modified: |
439 self.__saveChanges() |
434 self.__saveChanges() |
440 |
435 |
441 def __saveChanges(self): |
436 def __saveChanges(self): |
442 """Writes changes to the configuration file.""" |
437 """Writes changes to the configuration file.""" |
443 self.set('config.done', True) |
|
444 copy2(self.__cfgFileName, self.__cfgFileName+'.bak') |
438 copy2(self.__cfgFileName, self.__cfgFileName+'.bak') |
445 self.__cfgFile = open(self.__cfgFileName, 'w') |
439 self.__cfgFile = open(self.__cfgFileName, 'w') |
446 self.write(self.__cfgFile) |
440 self.write(self.__cfgFile) |
447 self.__cfgFile.close() |
441 self.__cfgFile.close() |
448 |
442 |