update_config_0.4.x-0.5.py
changeset 68 7ae95b9938c4
child 86 e43e4e7e9ec0
equal deleted inserted replaced
67:e4d25f50164d 68:7ae95b9938c4
       
     1 #!/usr/bin/env python
       
     2 # -*- coding: UTF-8 -*-
       
     3 # Copyright 2008 VEB IT
       
     4 # See COPYING for distribution information.
       
     5 # $Id$
       
     6 
       
     7 from ConfigParser import ConfigParser
       
     8 from shutil import copy2
       
     9 
       
    10 cf = '/usr/local/etc/vmm.cfg'
       
    11 fh = file(cf, 'r')
       
    12 cp = ConfigParser()
       
    13 cp.readfp(fh)
       
    14 fh.close()
       
    15 
       
    16 if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
       
    17         'folders') or cp.has_option('maildir', 'folder'):
       
    18     copy2(cf, cf+'.bak_upd_0.4.x-0.5')
       
    19     fh = file(cf, 'w')
       
    20     if not cp.has_option('maildir', 'name'):
       
    21         if cp.has_option('maildir', 'folder'):
       
    22             cp.set('maildir', 'name', cp.get('maildir', 'folder'))
       
    23             cp.remove_option('maildir', 'folder')
       
    24         else:
       
    25             cp.set('maildir', 'name', 'Maildir')
       
    26     if not cp.has_option('maildir', 'folders'):
       
    27         cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
       
    28     if cp.has_option('maildir', 'folder'):
       
    29         cp.remove_option('maildir', 'folder')
       
    30     cp.write(fh)
       
    31     fh.close()