--- a/VirtualMailManager/cli/main.py Sun Nov 11 16:53:52 2012 +0000
+++ b/VirtualMailManager/cli/main.py Tue Nov 20 13:40:32 2012 +0000
@@ -8,7 +8,7 @@
VirtualMailManager's command line interface.
"""
-from ConfigParser import NoOptionError, NoSectionError
+from configparser import NoOptionError, NoSectionError
from VirtualMailManager import ENCODING, errors
from VirtualMailManager.config import BadOptionError, ConfigValueError
@@ -28,8 +28,8 @@
try:
handler = CliHandler()
except (errors.NotRootError, errors.PermissionError, errors.VMMError,
- errors.ConfigError), err:
- w_err(err.code, _(u'Error: %s') % err.msg)
+ errors.ConfigError) as err:
+ w_err(err.code, _('Error: %s') % err.msg)
else:
handler.cfg_install()
return handler
@@ -38,19 +38,19 @@
def run(argv):
update_cmd_map()
if len(argv) < 2:
- usage(EX_MISSING_ARGS, _(u"You must specify a subcommand at least."))
+ usage(EX_MISSING_ARGS, _("You must specify a subcommand at least."))
sub_cmd = argv[1].lower()
if sub_cmd in cmd_map:
cmd_func = cmd_map[sub_cmd].func
else:
- for cmd in cmd_map.itervalues():
+ for cmd in cmd_map.values():
if cmd.alias == sub_cmd:
cmd_func = cmd.func
sub_cmd = cmd.name
break
else:
- usage(EX_UNKNOWN_COMMAND, _(u"Unknown subcommand: '%s'") % sub_cmd)
+ usage(EX_UNKNOWN_COMMAND, _("Unknown subcommand: '%s'") % sub_cmd)
handler = _get_handler()
run_ctx = RunContext(argv, handler, sub_cmd)
@@ -59,24 +59,24 @@
except (EOFError, KeyboardInterrupt):
# TP: We have to cry, because root has killed/interrupted vmm
# with Ctrl+C or Ctrl+D.
- w_err(EX_USER_INTERRUPT, '', _(u'Ouch!'), '')
- except errors.VMMError, err:
+ w_err(EX_USER_INTERRUPT, '', _('Ouch!'), '')
+ except errors.VMMError as err:
if err.code != DATABASE_ERROR:
if handler.has_warnings():
- w_err(0, _(u'Warnings:'), *handler.get_warnings())
- w_err(err.code, _(u'Error: %s') % err.msg)
- w_err(err.code, unicode(err.msg, ENCODING, 'replace'))
- except (BadOptionError, ConfigValueError), err:
- w_err(INVALID_ARGUMENT, _(u'Error: %s') % err)
- except NoSectionError, err:
+ w_err(0, _('Warnings:'), *handler.get_warnings())
+ w_err(err.code, _('Error: %s') % err.msg)
+ w_err(err.code, str(err.msg, ENCODING, 'replace'))
+ except (BadOptionError, ConfigValueError) as err:
+ w_err(INVALID_ARGUMENT, _('Error: %s') % err)
+ except NoSectionError as err:
w_err(INVALID_ARGUMENT,
- _(u"Error: Unknown section: '%s'") % err.section)
- except NoOptionError, err:
+ _("Error: Unknown section: '%s'") % err.section)
+ except NoOptionError as err:
w_err(INVALID_ARGUMENT,
- _(u"Error: No option '%(option)s' in section: '%(section)s'") %
+ _("Error: No option '%(option)s' in section: '%(section)s'") %
{'option': err.option, 'section': err.section})
if handler.has_warnings():
- w_err(0, _(u'Warnings:'), *handler.get_warnings())
+ w_err(0, _('Warnings:'), *handler.get_warnings())
return EX_SUCCESS
del _