VirtualMailManager/cli/__init__.py
branchv0.7.x
changeset 643 df1e3b67882a
parent 568 14abdd04ddf5
child 653 cf07e4468934
equal deleted inserted replaced
642:4cd9d0a9f42f 643:df1e3b67882a
    73     """Interactive 'password chat', returns the password in plain format.
    73     """Interactive 'password chat', returns the password in plain format.
    74 
    74 
    75     Throws a VMMError after the third failure.
    75     Throws a VMMError after the third failure.
    76     """
    76     """
    77     # TP: Please preserve the trailing space.
    77     # TP: Please preserve the trailing space.
    78     readp_msg0 = _(u'Enter new password: ').encode(ENCODING, 'replace')
    78     readp_msg0 = _('Enter new password: ').encode(ENCODING, 'replace')
    79     # TP: Please preserve the trailing space.
    79     # TP: Please preserve the trailing space.
    80     readp_msg1 = _(u'Retype new password: ').encode(ENCODING, 'replace')
    80     readp_msg1 = _('Retype new password: ').encode(ENCODING, 'replace')
    81     mismatched = True
    81     mismatched = True
    82     failures = 0
    82     failures = 0
    83     while mismatched:
    83     while mismatched:
    84         if failures > 2:
    84         if failures > 2:
    85             raise VMMError(_(u'Too many failures - try again later.'),
    85             raise VMMError(_('Too many failures - try again later.'),
    86                            VMM_TOO_MANY_FAILURES)
    86                            VMM_TOO_MANY_FAILURES)
    87         clear0 = getpass(prompt=readp_msg0)
    87         clear0 = getpass(prompt=readp_msg0)
    88         clear1 = getpass(prompt=readp_msg1)
    88         clear1 = getpass(prompt=readp_msg1)
    89         if clear0 != clear1:
    89         if clear0 != clear1:
    90             failures += 1
    90             failures += 1
    91             w_err(0, _(u'Sorry, passwords do not match.'))
    91             w_err(0, _('Sorry, passwords do not match.'))
    92             continue
    92             continue
    93         if not clear0:
    93         if not clear0:
    94             failures += 1
    94             failures += 1
    95             w_err(0, _(u'Sorry, empty passwords are not permitted.'))
    95             w_err(0, _('Sorry, empty passwords are not permitted.'))
    96             continue
    96             continue
    97         mismatched = False
    97         mismatched = False
    98     return clear0
    98     return clear0
    99 
    99 
   100 del _
   100 del _