VirtualMailManager/cli/handler.py
branchv0.6.x
changeset 339 abff2de9eed0
parent 337 150ddcc8b315
child 341 6709d0faf2f5
equal deleted inserted replaced
338:45834dcc280e 339:abff2de9eed0
    12 
    12 
    13 from VirtualMailManager.errors import VMMError
    13 from VirtualMailManager.errors import VMMError
    14 from VirtualMailManager.handler import Handler
    14 from VirtualMailManager.handler import Handler
    15 from VirtualMailManager.cli import read_pass
    15 from VirtualMailManager.cli import read_pass
    16 from VirtualMailManager.cli.config import CliConfig as Cfg
    16 from VirtualMailManager.cli.config import CliConfig as Cfg
    17 from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION
    17 from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION, \
       
    18      NO_SUCH_ACCOUNT
    18 
    19 
    19 _ = lambda msg: msg
    20 _ = lambda msg: msg
    20 
    21 
    21 
    22 
    22 class CliHandler(Handler):
    23 class CliHandler(Handler):
    79         acc.set_password(password)
    80         acc.set_password(password)
    80         acc.save()
    81         acc.save()
    81         self._make_account_dirs(acc)
    82         self._make_account_dirs(acc)
    82 
    83 
    83     def user_password(self, emailaddress, password=None):
    84     def user_password(self, emailaddress, password=None):
    84         """Prefix the parent user_password() with the interactive password
    85         """Override the parent user_password() - add the interactive
    85         dialog."""
    86         password dialog."""
    86         if password is None:
    87         acc = self._get_account(emailaddress)
       
    88         if not acc:
       
    89             raise VMMError(_(u"The account '%s' doesn't exist.") %
       
    90                            acc.address, NO_SUCH_ACCOUNT)
       
    91         if not isinstance(password, basestring) or not password:
    87             password = read_pass()
    92             password = read_pass()
    88         super(CliHandler, self).user_password(emailaddress, password)
    93         acc.modify('password', password)
    89 
    94 
    90 del _
    95 del _