VirtualMailManager/cli/handler.py
branchv0.7.x
changeset 643 df1e3b67882a
parent 568 14abdd04ddf5
child 676 2bc11dada296
equal deleted inserted replaced
642:4cd9d0a9f42f 643:df1e3b67882a
    61         if section is None:
    61         if section is None:
    62             self._cfg.configure(self._cfg.sections())
    62             self._cfg.configure(self._cfg.sections())
    63         elif self._cfg.has_section(section):
    63         elif self._cfg.has_section(section):
    64             self._cfg.configure([section])
    64             self._cfg.configure([section])
    65         else:
    65         else:
    66             raise VMMError(_(u"Invalid section: '%s'") % section,
    66             raise VMMError(_("Invalid section: '%s'") % section,
    67                            INVALID_SECTION)
    67                            INVALID_SECTION)
    68 
    68 
    69     def user_add(self, emailaddress, password=None):
    69     def user_add(self, emailaddress, password=None):
    70         """Override the parent user_add() - add the interactive password
    70         """Override the parent user_add() - add the interactive password
    71         dialog.
    71         dialog.
    72 
    72 
    73         Returns the generated password, if account.random_password == True.
    73         Returns the generated password, if account.random_password == True.
    74         """
    74         """
    75         acc = self._get_account(emailaddress)
    75         acc = self._get_account(emailaddress)
    76         if acc:
    76         if acc:
    77             raise VMMError(_(u"The account '%s' already exists.") %
    77             raise VMMError(_("The account '%s' already exists.") %
    78                            acc.address, ACCOUNT_EXISTS)
    78                            acc.address, ACCOUNT_EXISTS)
    79         self._is_other_address(acc.address, TYPE_ACCOUNT)
    79         self._is_other_address(acc.address, TYPE_ACCOUNT)
    80         rand_pass = self._cfg.dget('account.random_password')
    80         rand_pass = self._cfg.dget('account.random_password')
    81         if password is None:
    81         if password is None:
    82             password = (read_pass, randompw)[rand_pass]()
    82             password = (read_pass, randompw)[rand_pass]()
    88     def user_password(self, emailaddress, password=None):
    88     def user_password(self, emailaddress, password=None):
    89         """Override the parent user_password() - add the interactive
    89         """Override the parent user_password() - add the interactive
    90         password dialog."""
    90         password dialog."""
    91         acc = self._get_account(emailaddress)
    91         acc = self._get_account(emailaddress)
    92         if not acc:
    92         if not acc:
    93             raise VMMError(_(u"The account '%s' does not exist.") %
    93             raise VMMError(_("The account '%s' does not exist.") %
    94                            acc.address, NO_SUCH_ACCOUNT)
    94                            acc.address, NO_SUCH_ACCOUNT)
    95         if not isinstance(password, basestring) or not password:
    95         if not isinstance(password, str) or not password:
    96             password = read_pass()
    96             password = read_pass()
    97         acc.modify('password', password)
    97         acc.modify('password', password)
    98 
    98 
    99 del _
    99 del _