VirtualMailManager/Config.py
changeset 112 d1f345f91e1c
parent 103 edac75d0b435
child 113 e35755191ff3
equal deleted inserted replaced
111:50ff50f5055e 112:d1f345f91e1c
    18 from Exceptions import VMMConfigException
    18 from Exceptions import VMMConfigException
    19 import constants.ERROR as ERR
    19 import constants.ERROR as ERR
    20 
    20 
    21 locale.setlocale(locale.LC_ALL, '')
    21 locale.setlocale(locale.LC_ALL, '')
    22 ENCODING = locale.nl_langinfo(locale.CODESET)
    22 ENCODING = locale.nl_langinfo(locale.CODESET)
       
    23 
       
    24 def w_std(*args):
       
    25     for arg in args:
       
    26         sys.stdout.write(arg.encode(ENCODING, 'replace'))
       
    27         sys.stdout.write('\n')
    23 
    28 
    24 class Config(ConfigParser):
    29 class Config(ConfigParser):
    25     """This class is for configure the Virtual Mail Manager.
    30     """This class is for configure the Virtual Mail Manager.
    26 
    31 
    27     You can specify settings for the database connection
    32     You can specify settings for the database connection
   123             if not self.getboolean('config', 'done'):
   128             if not self.getboolean('config', 'done'):
   124                 self.__changes = True
   129                 self.__changes = True
   125         except ValueError:
   130         except ValueError:
   126             self.set('config', 'done', 'False')
   131             self.set('config', 'done', 'False')
   127             self.__changes = True
   132             self.__changes = True
   128         print _(u"Using configuration file: %s\n").encode(ENCODING,
   133         w_std(_(u'Using configuration file: %s\n') % self.__cfgFileName)
   129                 'replace') % self.__cfgFileName
       
   130         for s in sections:
   134         for s in sections:
   131             if s != 'config':
   135             if s != 'config':
   132                 print _(u'* Config section: »%s«').encode(ENCODING,'replace')%s
   136                 w_std(_(u'* Config section: »%s«') % s )
   133             for opt, val in self.items(s):
   137             for opt, val in self.items(s):
   134                 newval = raw_input(
   138                 newval = raw_input(
   135                 _('Enter new value for option %(opt)s [%(val)s]: ').encode(
   139                 _('Enter new value for option %(opt)s [%(val)s]: ').encode(
   136                     ENCODING, 'replace') % {'opt': opt, 'val': val})
   140                     ENCODING, 'replace') % {'opt': opt, 'val': val})
   137                 if newval and newval != val:
   141                 if newval and newval != val: