diff -r 4cd9d0a9f42f -r df1e3b67882a VirtualMailManager/cli/config.py --- a/VirtualMailManager/cli/config.py Sun Nov 11 16:53:52 2012 +0000 +++ b/VirtualMailManager/cli/config.py Tue Nov 20 13:40:32 2012 +0000 @@ -8,7 +8,7 @@ Adds some interactive stuff to the Config class. """ -from ConfigParser import RawConfigParser +from configparser import RawConfigParser from shutil import copy2 from VirtualMailManager import ENCODING @@ -29,33 +29,33 @@ def configure(self, sections): """Interactive method for configuring all options of the given iterable ``sections`` object.""" - input_fmt = _(u'Enter new value for option %(option)s ' - u'[%(current_value)s]: ') + input_fmt = _('Enter new value for option %(option)s ' + '[%(current_value)s]: ') failures = 0 - w_std(_(u'Using configuration file: %s\n') % self._cfg_filename) + w_std(_('Using configuration file: %s\n') % self._cfg_filename) for section in sections: - w_std(_(u"* Configuration section: '%s'") % section) + w_std(_("* Configuration section: '%s'") % section) for opt, val in self.items(section): failures = 0 while True: - newval = raw_input(input_fmt.encode(ENCODING, 'replace') % + newval = input(input_fmt.encode(ENCODING, 'replace') % {'option': opt, 'current_value': val}) if newval and newval != val: try: LazyConfig.set(self, '%s.%s' % (section, opt), newval) break - except (ValueError, ConfigValueError, VMMError), err: - w_err(0, _(u'Warning: %s') % err) + except (ValueError, ConfigValueError, VMMError) as err: + w_err(0, _('Warning: %s') % err) failures += 1 if failures > 2: - raise ConfigError(_(u'Too many failures - try ' - u'again later.'), + raise ConfigError(_('Too many failures - try ' + 'again later.'), VMM_TOO_MANY_FAILURES) else: break - print + print() if self._modified: self._save_changes() @@ -72,7 +72,7 @@ val = self._cfg[section][option_].cls(value) if self._cfg[section][option_].validate: val = self._cfg[section][option_].validate(val) - except (ValueError, ConfigValueError), err: + except (ValueError, ConfigValueError) as err: raise ConfigError(str(err), CONF_ERROR) # Do not write default values also skip identical values if not self._cfg[section][option_].default is None: