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()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
68
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# Copyright 2008 VEB IT
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
# $Id$
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
from ConfigParser import ConfigParser
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
from shutil import copy2
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
cf = '/usr/local/etc/vmm.cfg'
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
fh = file(cf, 'r')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
cp = ConfigParser()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    13
cp.readfp(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
fh.close()
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
        'folders') or cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
    copy2(cf, cf+'.bak_upd_0.4.x-0.5')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    19
    fh = file(cf, 'w')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    20
    if not cp.has_option('maildir', 'name'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    21
        if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
            cp.set('maildir', 'name', cp.get('maildir', 'folder'))
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
            cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    24
        else:
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    25
            cp.set('maildir', 'name', 'Maildir')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
    if not cp.has_option('maildir', 'folders'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    27
        cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    28
    if cp.has_option('maildir', 'folder'):
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    29
        cp.remove_option('maildir', 'folder')
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    30
    cp.write(fh)
7ae95b9938c4 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    31
    fh.close()