VirtualMailManager/cli/handler.py
branchv0.6.x
changeset 375 4cbaf8d229f9
parent 366 d6573da35b5f
child 417 8209da83e256
equal deleted inserted replaced
374:ecdba68c7a2c 375:4cbaf8d229f9
     9 """
     9 """
    10 
    10 
    11 import os
    11 import os
    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, TYPE_ACCOUNT
    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      NO_SUCH_ACCOUNT
    19 from VirtualMailManager.password import randompw
    19 from VirtualMailManager.password import randompw
    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(_(u"The account '%s' already exists.") %
    78                            acc.address, ACCOUNT_EXISTS)
    78                            acc.address, ACCOUNT_EXISTS)
       
    79         other = self._is_other_address(acc.address, TYPE_ACCOUNT)
    79         rand_pass = self._cfg.dget('account.random_password')
    80         rand_pass = self._cfg.dget('account.random_password')
    80         if password is None:
    81         if password is None:
    81             password = (read_pass, randompw)[rand_pass]()
    82             password = (read_pass, randompw)[rand_pass]()
    82         acc.set_password(password)
    83         acc.set_password(password)
    83         acc.save()
    84         acc.save()