equal
deleted
inserted
replaced
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() |