VirtualMailManager/Config.py
changeset 34 6d74e20c5b3b
parent 32 ceb700bc4a80
child 47 191d5a5adc4a
equal deleted inserted replaced
33:bee57f4616a2 34:6d74e20c5b3b
    67                 ['pop3', 'true'],
    67                 ['pop3', 'true'],
    68                 ['imap', 'true'],
    68                 ['imap', 'true'],
    69                 ['managesieve', 'true']
    69                 ['managesieve', 'true']
    70                 ]
    70                 ]
    71         self.__domdopts = [
    71         self.__domdopts = [
    72                 ['base', '/home/mail'],
    72                 ['base', '/srv/mail'],
    73                 ['mode', 504],
    73                 ['mode', 504],
    74                 ['delete', 'false']
    74                 ['delete', 'false']
    75                 ]
    75                 ]
    76         self.__binopts = [
    76         self.__binopts = [
    77                 ['dovecotpw', '/usr/sbin/dovecotpw'],
    77                 ['dovecotpw', '/usr/sbin/dovecotpw'],
    96     def check(self):
    96     def check(self):
    97         if not self.__chkSections():
    97         if not self.__chkSections():
    98             errmsg = StringIO()
    98             errmsg = StringIO()
    99             for k,v in self.__missing.items():
    99             for k,v in self.__missing.items():
   100                 if v[0] is True:
   100                 if v[0] is True:
   101                     errmsg.write("missing section: %s\n" % k)
   101                     errmsg.write(_("missing section: %s\n") % k)
   102                 else:
   102                 else:
   103                     errmsg.write("missing options in section %s:\n" % k)
   103                     errmsg.write(_("missing options in section %s:\n") % k)
   104                     for o in v:
   104                     for o in v:
   105                         errmsg.write(" * %s\n" % o)
   105                         errmsg.write(" * %s\n" % o)
   106             raise VMMConfigException((errmsg.getvalue(), ERR.CONF_ERROR))
   106             raise VMMConfigException((errmsg.getvalue(), ERR.CONF_ERROR))
   107 
   107 
   108     def getsections(self):
   108     def getsections(self):
   114 
   114 
   115         Keyword arguments:
   115         Keyword arguments:
   116         sections -- list of strings
   116         sections -- list of strings
   117         """
   117         """
   118         if not isinstance(sections, list):
   118         if not isinstance(sections, list):
   119             raise TypeError("Argument 'sections' is not a list.")
   119             raise TypeError(_("Argument 'sections' is not a list."))
   120         # if [config] done = false (default at 1st run),
   120         # if [config] done = false (default at 1st run),
   121         # then set changes true
   121         # then set changes true
   122         try:
   122         try:
   123             if not self.getboolean('config', 'done'):
   123             if not self.getboolean('config', 'done'):
   124                 self.__changes = True
   124                 self.__changes = True
   127             self.__changes = True
   127             self.__changes = True
   128         for s in sections:
   128         for s in sections:
   129             if s == 'config':
   129             if s == 'config':
   130                 pass
   130                 pass
   131             else:
   131             else:
   132                 print '* Config section: %s' % s
   132                 print _('* Config section: %s') % s
   133             for opt, val in self.items(s):
   133             for opt, val in self.items(s):
   134                 newval = raw_input('Enter new value for %s [%s]: ' %(opt, val))
   134                 newval = raw_input(_('Enter new value for %s [%s]: ')
       
   135                         %(opt, val))
   135                 if newval and newval != val:
   136                 if newval and newval != val:
   136                     self.set(s, opt, newval)
   137                     self.set(s, opt, newval)
   137                     self.__changes = True
   138                     self.__changes = True
   138             print
   139             print
   139         if self.__changes:
   140         if self.__changes: