VirtualMailManager/cli/Handler.py
branchv0.6.x
changeset 277 e50ffc0b8468
parent 216 0c8c053b451c
child 279 74d94b867348
equal deleted inserted replaced
276:f2ecfe0a0e09 277:e50ffc0b8468
    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
    19 
    19 
       
    20 _ = lambda msg: msg
       
    21 
    20 
    22 
    21 class CliHandler(Handler):
    23 class CliHandler(Handler):
    22     """This class uses a `CliConfig` for configuration stuff, instead of
    24     """This class uses a `CliConfig` for configuration stuff, instead of
    23     the non-interactive `Config` class.
    25     the non-interactive `Config` class.
    24 
    26 
    26 
    28 
    27     Additionally it uses `VirtualMailManager.cli.read_pass()` for for the
    29     Additionally it uses `VirtualMailManager.cli.read_pass()` for for the
    28     interactive password dialog.
    30     interactive password dialog.
    29     """
    31     """
    30 
    32 
    31     __slots__ = ()# nothing additional, also no __dict__/__weakref__
    33     __slots__ = ()  # nothing additional, also no __dict__/__weakref__
    32 
    34 
    33     def __init__(self):
    35     def __init__(self):
    34         """Creates a new CliHandler instance.
    36         """Creates a new CliHandler instance.
    35 
    37 
    36         Throws a NotRootError if your uid is greater 0.
    38         Throws a NotRootError if your uid is greater 0.
    65             self._Cfg.configure([section])
    67             self._Cfg.configure([section])
    66         else:
    68         else:
    67             raise VMMError(_(u'Invalid section: ā€œ%sā€') % section,
    69             raise VMMError(_(u'Invalid section: ā€œ%sā€') % section,
    68                            INVALID_SECTION)
    70                            INVALID_SECTION)
    69 
    71 
    70     def userAdd(self, emailaddress, password):
    72     def user_add(self, emailaddress, password=None):
       
    73         """Prefix the parent user_add() with the interactive password
       
    74         dialog."""
    71         if password is None:
    75         if password is None:
    72             password = read_pass()
    76             password = read_pass()
    73         super(CliHandler, self).userAdd(emailaddress, password)
    77         super(CliHandler, self).user_add(emailaddress, password)
    74 
    78 
    75     def userPassword(self, emailaddress, password):
    79     def user_password(self, emailaddress, password=None):
       
    80         """Prefix the parent user_password() with the interactive password
       
    81         dialog."""
    76         if password is None:
    82         if password is None:
    77             password = read_pass()
    83             password = read_pass()
    78         super(CliHandler, self).userPassword(emailaddress, password)
    84         super(CliHandler, self).user_password(emailaddress, password)
       
    85 
       
    86 del _