update_config_0.4.x-0.5.py
author Pascal Volk <neverseen@users.sourceforge.net>
Mon, 08 Sep 2008 05:30:17 +0000
changeset 76 14c0a092d7d2
parent 68 7ae95b9938c4
child 86 e43e4e7e9ec0
permissions -rwxr-xr-x
* 'VirtualMailManager/EmailAddress.py' - Added to repository - to simplify/reduce address validation. * 'VirtualMailManager/Relocated.py' - Added to repository * 'VirtualMailManager/Exceptions.py' - Added exception classes for class EmailAddress and class Relocated * 'VirtualMailManager/constants/ERROR.py' - Updated - Removed shebang * 'VirtualMailManager/VirtualMailManager.py' - Moved static methods chkLocalpart() and chkEmailAddress to new class EmailAddress - Added static methods accountExists(), aliasExists(), relocatedExists() and _exists() - Fixed a bug in VirtualMailManager._readpass() - Integrated class EmailAddress * 'VirtualMailManager/Alias.py' - Integrated class EmailAddress - Removed Alias._isAccount() * 'VirtualMailManager/Account.py' - Integrated class EmailAddress - Removed Account._isAlias() * 'VirtualMailManager/AliasDomain.py' * 'VirtualMailManager/Config.py' * 'VirtualMailManager/Domain.py' * 'VirtualMailManager/MailLocation.py' * 'VirtualMailManager/Transport.py' * 'VirtualMailManager/constants/EXIT.py' - Removed shebang * 'vmm' - more detailed error messages from alias_add()

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright 2008 VEB IT
# See COPYING for distribution information.
# $Id$

from ConfigParser import ConfigParser
from shutil import copy2

cf = '/usr/local/etc/vmm.cfg'
fh = file(cf, 'r')
cp = ConfigParser()
cp.readfp(fh)
fh.close()

if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
        'folders') or cp.has_option('maildir', 'folder'):
    copy2(cf, cf+'.bak_upd_0.4.x-0.5')
    fh = file(cf, 'w')
    if not cp.has_option('maildir', 'name'):
        if cp.has_option('maildir', 'folder'):
            cp.set('maildir', 'name', cp.get('maildir', 'folder'))
            cp.remove_option('maildir', 'folder')
        else:
            cp.set('maildir', 'name', 'Maildir')
    if not cp.has_option('maildir', 'folders'):
        cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
    if cp.has_option('maildir', 'folder'):
        cp.remove_option('maildir', 'folder')
    cp.write(fh)
    fh.close()