2008-01-13 21:14:38 -05:00
|
|
|
import sys, ldap, termios
|
2008-01-10 23:59:25 -05:00
|
|
|
from getopt import getopt
|
2008-01-25 20:24:00 -05:00
|
|
|
from ceo import members, terms, uwldap, ldapi
|
|
|
|
|
|
|
|
from ceo.console.memberlist import MemberList
|
|
|
|
from ceo.console.updateprograms import UpdatePrograms
|
|
|
|
from ceo.console.expiredaccounts import ExpiredAccounts
|
2008-03-10 00:25:08 -04:00
|
|
|
from ceo.console.inactive import Inactive
|
2008-01-25 20:24:00 -05:00
|
|
|
|
|
|
|
commands = {
|
|
|
|
'memberlist' : MemberList(),
|
|
|
|
'updateprograms' : UpdatePrograms(),
|
|
|
|
'expiredaccounts' : ExpiredAccounts(),
|
2008-03-10 00:25:08 -04:00
|
|
|
'inactive': Inactive(),
|
2008-01-25 20:24:00 -05:00
|
|
|
}
|
2008-01-13 21:14:38 -05:00
|
|
|
|
2008-01-10 23:59:25 -05:00
|
|
|
shortopts = [
|
|
|
|
]
|
|
|
|
|
|
|
|
longopts = [
|
|
|
|
]
|
|
|
|
|
|
|
|
def start():
|
|
|
|
(opts, args) = getopt(sys.argv[1:], shortopts, longopts)
|
2008-01-23 02:11:43 -05:00
|
|
|
if len(args) >= 1:
|
2008-01-13 21:14:38 -05:00
|
|
|
if args[0] in commands:
|
2008-03-28 15:46:32 -04:00
|
|
|
command = commands[args[0]]
|
|
|
|
if len(args) >= 2 and args[1] in ['--help', '-h']:
|
|
|
|
print command.help
|
|
|
|
else:
|
|
|
|
command.main(args[1:])
|
2008-01-10 23:59:25 -05:00
|
|
|
else:
|
2008-01-13 21:14:38 -05:00
|
|
|
print "Invalid command '%s'" % args[0]
|
2008-01-10 23:59:25 -05:00
|
|
|
|
|
|
|
def help():
|
2008-03-28 15:46:32 -04:00
|
|
|
args = sys.argv[2:]
|
|
|
|
if len(args) == 1:
|
|
|
|
if args[0] in commands:
|
|
|
|
print commands[args[0]].help
|
|
|
|
else:
|
|
|
|
print 'Unknown command %s.' % args[0]
|
|
|
|
else:
|
|
|
|
print ''
|
|
|
|
print 'Available commands:'
|
|
|
|
for c in commands:
|
|
|
|
print ' %s' % c
|
|
|
|
print ''
|
|
|
|
print 'Run \'ceo command --help\' for help on a specific command.'
|
|
|
|
print ''
|