VirtualMailManager/__init__.py
author Pascal Volk <neverseen@users.sourceforge.net>
Wed, 13 Jan 2010 00:08:44 +0000
branchv0.6.x
changeset 166 b152ad5c7071
parent 162 0ac9ef587769
child 174 974bafa59330
permissions -rw-r--r--
vmm.cfg: dealt with the most overdue section/option renaming. Added new options. Details: old new ------------------------------------------------------------ domdir.mode -> domain.directory_mode domdir.delete -> domain.delete_directory domdir.base -> misc.base_dir domdir -> _section domdir deleted_ maildir.mode -> account.directory_mode maildir.diskusage -> account.disk_usage maildir.delete -> account.delete_directory misc.forcedel -> domain.force_del misc.passwdscheme -> misc.password_scheme misc.dovecotvers -> misc.dovecot_vers services.smtp -> account.smtp services.pop3 -> account.pop3 services.imap -> account.imap services.sieve -> account.sieve services -> _section services deleted_ _NEW_.random_password -> account.random_password _NEW_.password_len -> account.password_len _NEW_.auto_postmaster -> domain.auto_postmaster
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
# -*- coding: UTF-8 -*-
162
0ac9ef587769 Updated copyright notices to include the year 2010.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 152
diff changeset
     2
# Copyright (c) 2007 - 2010, Pascal Volk
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# See COPYING for distribution information.
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
     4
# package initialization code
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
#
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
     6
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
     7
import os
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
     8
import re
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
     9
import locale
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    10
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    11
from constants.VERSION import *
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    12
import constants.ERROR as ERR
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    13
152
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    14
# Try to set all of the locales according to the current
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    15
# environment variables and get the character encoding.
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    16
try:
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    17
    locale.setlocale(locale.LC_ALL, '')
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    18
except locale.Error:
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    19
    locale.setlocale(locale.LC_ALL, 'C')
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    20
ENCODING = locale.nl_langinfo(locale.CODESET)
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    21
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    22
def w_std(*args):
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    23
    """Writes each arg of args, encoded in the current ENCODING, to stdout and
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    24
    appends a newline."""
141
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    25
    _write = os.sys.stdout.write
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    26
    for arg in args:
141
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    27
        _write(arg.encode(ENCODING, 'replace'))
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    28
        _write('\n')
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    29
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    30
def w_err(code, *args):
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    31
    """Writes each arg of args, encoded in the current ENCODING, to stderr and
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    32
    appends a newline.
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    33
    This function additional interrupts the program execution and uses 'code'
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    34
    system exit status."""
141
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    35
    _write = os.sys.stderr.write
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    36
    for arg in args:
141
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    37
        _write(arg.encode(ENCODING, 'replace'))
ecd6a379e523 Small optimization in w_std()/w_err() 'avoid the dot'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    38
        _write('\n')
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    39
    os.sys.exit(code)
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    40
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    41
__all__ = [
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    42
        # imported modules
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    43
        'os', 're', 'locale',
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    44
        # version information from VERSION
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    45
        '__author__', '__date__', '__version__',
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    46
        # error codes
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    47
        'ERR',
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    48
        # defined stuff
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    49
        'ENCODING', 'w_std', 'w_err'
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    50
        ]
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    51
# EOF