vmm
changeset 4 f3c30b7421b9
parent 3 a9b44e04bf01
child 5 d7cb92d42d62
equal deleted inserted replaced
3:a9b44e04bf01 4:f3c30b7421b9
     4 # See COPYING for distribution information.
     4 # See COPYING for distribution information.
     5 # $Id$
     5 # $Id$
     6 
     6 
     7 """This is the vmm main script."""
     7 """This is the vmm main script."""
     8 
     8 
       
     9 from VirtualMailManager.constants.VERSION import VERSION
       
    10 
     9 __author__ = 'Pascal Volk <p.volk@veb-it.de>'
    11 __author__ = 'Pascal Volk <p.volk@veb-it.de>'
    10 __version__ = 'rev '+'$Rev$'.split()[1]
    12 __version__ = VERSION
       
    13 __revision__ = 'rev '+'$Rev$'.split()[1]
    11 __date__ = '$Date$'.split()[1]
    14 __date__ = '$Date$'.split()[1]
    12 
    15 
    13 import os
    16 import os
    14 import sys
    17 import sys
    15 from getpass import getpass
    18 from getpass import getpass
    17 from VirtualMailManager.VirtualMailManager import VirtualMailManager
    20 from VirtualMailManager.VirtualMailManager import VirtualMailManager
    18 from VirtualMailManager.Config import VMMConfig
    21 from VirtualMailManager.Config import VMMConfig
    19 import VirtualMailManager.Exceptions as VMME
    22 import VirtualMailManager.Exceptions as VMME
    20 import VirtualMailManager.constants.EXIT as EXIT
    23 import VirtualMailManager.constants.EXIT as EXIT
    21 
    24 
       
    25 __prog__ = os.path.basename(sys.argv[0])
       
    26 
    22 def usage(excode=0, errMsg=None):
    27 def usage(excode=0, errMsg=None):
    23     sys.stderr.write("""\
    28     sys.stderr.write("""\
    24 Usage: vmm OPTION OBJECT ARGS*
    29 Usage: %s OPTION OBJECT ARGS*
    25   short long
    30   short long
    26   option                object           args (* = optional)
    31   option                object           args (* = optional)
    27 
    32 
    28   da    domainadd       domain.tld       transport*
    33   da    domainadd       domain.tld       transport*
    29   di    domaininfo      domain.tld       detailed*
    34   di    domaininfo      domain.tld       detailed*
    41   ad    aliasdelete     alias@domain.tld
    46   ad    aliasdelete     alias@domain.tld
    42   cf    configure                        section*
    47   cf    configure                        section*
    43   h     help
    48   h     help
    44   v     version
    49   v     version
    45 
    50 
    46 """)
    51 """) % __prog__
    47     if not errMsg is None:
    52     if not errMsg is None:
    48         sys.stderr.write('Error: %s\n' % errMsg)
    53         sys.stderr.write('Error: %s\n' % errMsg)
    49     sys.exit(excode)
    54     sys.exit(excode)
    50 
    55 
    51 def getVMM():
    56 def getVMM():
   283         elif sys.argv[1] in ['ad', 'aliasdelete']:
   288         elif sys.argv[1] in ['ad', 'aliasdelete']:
   284             alias_delete()
   289             alias_delete()
   285         elif sys.argv[1] in ['h', 'help']:
   290         elif sys.argv[1] in ['h', 'help']:
   286             usage()
   291             usage()
   287         elif sys.argv[1] in ['v', 'version']:
   292         elif sys.argv[1] in ['v', 'version']:
   288             print "%s: %s (Date: %s)\n" % (os.path.basename(sys.argv[0]),
   293             print "%s, version %s (%s from %s)\n" % (__prog__, __version__,
   289                     __version__, __date__)
   294                     __revision__, __date__)
   290         else:
   295         else:
   291             usage(EXIT.UNKNOWN_OPTION, 'Unknown option: »%s«' % sys.argv[1])
   296             usage(EXIT.UNKNOWN_OPTION, 'Unknown option: »%s«' % sys.argv[1])
   292         showWarnings()
   297         showWarnings()
   293     except (EOFError, KeyboardInterrupt):
   298     except (EOFError, KeyboardInterrupt):
   294         sys.stderr.write('\nOuch!\n')
   299         sys.stderr.write('\nOuch!\n')