equal
deleted
inserted
replaced
8 A derived Handler class with a few changes/additions for cli use. |
8 A derived Handler class with a few changes/additions for cli use. |
9 """ |
9 """ |
10 |
10 |
11 import os |
11 import os |
12 |
12 |
13 from VirtualMailManager.Exceptions import VMMException |
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.ERROR import INVALID_SECTION |
17 from VirtualMailManager.constants.ERROR import INVALID_SECTION |
18 from VirtualMailManager.ext.Postconf import Postconf |
18 from VirtualMailManager.ext.Postconf import Postconf |
31 __slots__ = ()# nothing additional, also no __dict__/__weakref__ |
31 __slots__ = ()# nothing additional, also no __dict__/__weakref__ |
32 |
32 |
33 def __init__(self): |
33 def __init__(self): |
34 """Creates a new CliHandler instance. |
34 """Creates a new CliHandler instance. |
35 |
35 |
36 Throws a VMMNotRootException if your uid is greater 0. |
36 Throws a NotRootError if your uid is greater 0. |
37 """ |
37 """ |
38 # Overwrite the parent CTor partly, we use the CliConfig class |
38 # Overwrite the parent CTor partly, we use the CliConfig class |
39 # and add some command line checks. |
39 # and add some command line checks. |
40 skip_some_checks = os.sys.argv[1] in ('cf', 'configure', 'h', 'help', |
40 skip_some_checks = os.sys.argv[1] in ('cf', 'configure', 'h', 'help', |
41 'v', 'version') |
41 'v', 'version') |
62 if section is None: |
62 if section is None: |
63 self._Cfg.configure(self._Cfg.sections()) |
63 self._Cfg.configure(self._Cfg.sections()) |
64 elif self._Cfg.has_section(section): |
64 elif self._Cfg.has_section(section): |
65 self._Cfg.configure([section]) |
65 self._Cfg.configure([section]) |
66 else: |
66 else: |
67 raise VMMException(_(u'Invalid section: ā%sā') % section, |
67 raise VMMError(_(u'Invalid section: ā%sā') % section, |
68 INVALID_SECTION) |
68 INVALID_SECTION) |
69 |
69 |
70 def userAdd(self, emailaddress, password): |
70 def userAdd(self, emailaddress, password): |
71 if password is None: |
71 if password is None: |
72 password = read_pass() |
72 password = read_pass() |
73 super(CliHandler, self).userAdd(emailaddress, password) |
73 super(CliHandler, self).userAdd(emailaddress, password) |