print "You must be root to add users" exit(0) parser.set_usage("usage: %s %s [options]" % (shell_cmd_name,cmd)) parser.add_option("-t", "--userType", dest="usertype",default=None, help="only list users of a certain type (teacher,student,parent or other)", metavar="USERTYPE") (options, args) = parser.parse_args() if options.usertype: intxt = options.usertype options.usertype = userdef.usertype_as_id(options.usertype) if not options.usertype: print "User type \"%s\" is not recognized. Following are valid: teacher,student,parent or other" % intxt options.usertype = None um = UserManager() ul = um.list_users(options.usertype) for k in ul.keys(): print k if cmd == "listusergroups": parser.set_usage("usage: %s %s username" % (shell_cmd_name,cmd)) (options, args) = parser.parse_args() if len(args)<2: print "Missing username for %s operation" % cmd exit(0) username = check_username(args[1]) if not username: print "The given username is invalid." exit(0)