VirtualMailManager/VirtualMailManager.py
changeset 96 e903c8baa72d
parent 94 0d303d15549e
child 102 485d3f7d6981
equal deleted inserted replaced
95:fc008eb12186 96:e903c8baa72d
    13 __date__ = '$Date$'.split()[1]
    13 __date__ = '$Date$'.split()[1]
    14 
    14 
    15 import os
    15 import os
    16 import re
    16 import re
    17 import sys
    17 import sys
       
    18 import locale
    18 from encodings.idna import ToASCII, ToUnicode
    19 from encodings.idna import ToASCII, ToUnicode
    19 from getpass import getpass
    20 from getpass import getpass
    20 from shutil import rmtree
    21 from shutil import rmtree
    21 from subprocess import Popen, PIPE
    22 from subprocess import Popen, PIPE
    22 
    23 
    37 RE_ASCII_CHARS = """^[\x20-\x7E]*$"""
    38 RE_ASCII_CHARS = """^[\x20-\x7E]*$"""
    38 RE_DOMAIN = """^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$"""
    39 RE_DOMAIN = """^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$"""
    39 RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$"""
    40 RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$"""
    40 RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]"""
    41 RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]"""
    41 RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$"""
    42 RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$"""
       
    43 locale.setlocale(locale.LC_ALL, '')
       
    44 ENCODING = locale.nl_langinfo(locale.CODESET)
    42 
    45 
    43 class VirtualMailManager:
    46 class VirtualMailManager:
    44     """The main class for vmm"""
    47     """The main class for vmm"""
    45     def __init__(self):
    48     def __init__(self):
    46         """Creates a new VirtualMailManager instance.
    49         """Creates a new VirtualMailManager instance.
   207         mismatched = True
   210         mismatched = True
   208         while mismatched:
   211         while mismatched:
   209             clear0 = getpass(prompt=_('Enter new password: '))
   212             clear0 = getpass(prompt=_('Enter new password: '))
   210             clear1 = getpass(prompt=_('Retype new password: '))
   213             clear1 = getpass(prompt=_('Retype new password: '))
   211             if clear0 != clear1:
   214             if clear0 != clear1:
   212                 sys.stderr.write('%s\n' % _('Sorry, passwords do not match'))
   215                 msg = _('Sorry, passwords do not match')
       
   216                 sys.stderr.write('%s\n' % msg.encode(ENCODING, 'replace'))
   213                 continue
   217                 continue
   214             if len(clear0) < 1 or len(clear1) < 1:
   218             if len(clear0) < 1 or len(clear1) < 1:
   215                 sys.stderr.write('%s\n'
   219                 msg = _('Sorry, empty passwords are not permitted')
   216                         % _('Sorry, empty passwords are not permitted'))
   220                 sys.stderr.write('%s\n' % msg.encode(ENCODING, 'replace'))
   217                 continue
   221                 continue
   218             mismatched = False
   222             mismatched = False
   219         return clear0
   223         return clear0
   220 
   224 
   221     def __getAccount(self, address, password=None):
   225     def __getAccount(self, address, password=None):