vmm
changeset 20 55146c78b3fb
parent 19 bf9a03c476fc
child 22 576a4709a44f
equal deleted inserted replaced
19:bf9a03c476fc 20:55146c78b3fb
    24 
    24 
    25 __prog__ = os.path.basename(sys.argv[0])
    25 __prog__ = os.path.basename(sys.argv[0])
    26 
    26 
    27 def usage(excode=0, errMsg=None):
    27 def usage(excode=0, errMsg=None):
    28     sys.stderr.write("""\
    28     sys.stderr.write("""\
    29 Usage: %s OPTION OBJECT ARGS*
    29 Usage: %s COMMAND OBJECT ARGS*
    30   short long
    30   short long
    31   option                object           args (* = optional)
    31   command               object           args (* = optional)
    32 
    32 
    33   da    domainadd       domain.tld       transport*
    33   da    domainadd       domain.tld       transport*
    34   di    domaininfo      domain.tld       detailed*
    34   di    domaininfo      domain.tld       detailed*
    35   dt    domaintransport domain.tld       transport force*
    35   dt    domaintransport domain.tld       transport force*
    36   dd    domaindelete    domain.tld       delalias*|deluser*|delall*
    36   dd    domaindelete    domain.tld       delalias*|deluser*|delall*
    37   ua    useradd         user@domain.tld  password*
    37   ua    useradd         user@domain.tld  password*
    38   ui    userinfo        user@domain.tld  du*
    38   ui    userinfo        user@domain.tld  du*
    39   un    username        user@domain.tld  'Users Name'
    39   un    username        user@domain.tld  'Users Name'
    40   up    userpassword    user@domain.tld  password*
    40   up    userpassword    user@domain.tld  password*
    41   ut    usertransport   user@domain.tld  transport
    41   ut    usertransport   user@domain.tld  transport
    42   u0    userdisable     user@domain.tld
    42   u0    userdisable     user@domain.tld  smtp*|pop3*|imap*|managesieve*|all*
    43   u1    userenable      user@domain.tld
    43   u1    userenable      user@domain.tld  smtp*|pop3*|imap*|managesieve*|all*
    44   ud    userdelete      user@domain.tld
    44   ud    userdelete      user@domain.tld
    45   aa    aliasadd        alias@domain.tld user@domain.tld
    45   aa    aliasadd        alias@domain.tld user@domain.tld
    46   ai    aliasinfo       alias@domain.tld
    46   ai    aliasinfo       alias@domain.tld
    47   ad    aliasdelete     alias@domain.tld user@domain.tld*
    47   ad    aliasdelete     alias@domain.tld user@domain.tld*
    48   gu    getuser         userid
    48   gu    getuser         userid
   207 
   207 
   208 def user_enable():
   208 def user_enable():
   209     global argc
   209     global argc
   210     if argc < 3:
   210     if argc < 3:
   211         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   211         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   212     else:
   212     elif argc < 4:
   213         vmm.user_enable(sys.argv[2].lower())
   213         vmm.user_enable(sys.argv[2].lower())
       
   214     else:
       
   215         vmm.user_enable(sys.argv[2].lower(), sys.argv[3].lower())
   214 
   216 
   215 def user_disable():
   217 def user_disable():
   216     global argc
   218     global argc
   217     if argc < 3:
   219     if argc < 3:
   218         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   220         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   219     else:
   221     elif argc < 4:
   220         vmm.user_disable(sys.argv[2].lower())
   222         vmm.user_disable(sys.argv[2].lower())
       
   223     else:
       
   224         vmm.user_disable(sys.argv[2].lower(), sys.argv[3].lower())
   221 
   225 
   222 def user_password():
   226 def user_password():
   223     global argc
   227     global argc
   224     if argc < 3:
   228     if argc < 3:
   225         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   229         usage(EXIT.MISSING_ARGS, 'Missing e-mail address.')
   317             usage()
   321             usage()
   318         elif sys.argv[1] in ['v', 'version']:
   322         elif sys.argv[1] in ['v', 'version']:
   319             print "%s, version %s (%s from %s)\n" % (__prog__, __version__,
   323             print "%s, version %s (%s from %s)\n" % (__prog__, __version__,
   320                     __revision__, __date__)
   324                     __revision__, __date__)
   321         else:
   325         else:
   322             usage(EXIT.UNKNOWN_OPTION, 'Unknown option: »%s«' % sys.argv[1])
   326             usage(EXIT.UNKNOWN_COMMAND, 'Unknown command: »%s«' % sys.argv[1])
   323         showWarnings()
   327         showWarnings()
   324     except (EOFError, KeyboardInterrupt):
   328     except (EOFError, KeyboardInterrupt):
   325         sys.stderr.write('\nOuch!\n')
   329         sys.stderr.write('\nOuch!\n')
   326         sys.exit(EXIT.USER_INTERRUPT)
   330         sys.exit(EXIT.USER_INTERRUPT)
   327     except VMME.VMMException, e:
   331     except VMME.VMMException, e: