parser.set_usage("usage: %s %s [options]" % (shell_cmd_name,cmd)) parser.add_option("-t", "--groupType", dest="grouptype",default=None, help="only list groups of a certain type (teacher,student,parent or other)", metavar="GROUPTYPE") parser.add_option("-n", "--groupname", dest="groupname",default=None, help="Limit the result to a certain group",metavar="GROUPNAME") (options, args) = parser.parse_args() if options.grouptype: intxt = options.grouptype options.grouptype = groupdef.grouptype_as_id(options.grouptype) if not options.grouptype: print "User type \"%s\" is not recognized. Following are valid: teacher,student,parent or other" % intxt options.grouptype = None gm = GroupManager() gl = gm.list_groups(options.grouptype,options.groupname) for k in gl.keys(): print k if cmd == "listmembers": parser.set_usage("usage: %s %s groupname" % (shell_cmd_name,cmd)) (options, args) = parser.parse_args() if len(args)<2: print "Missing group name for listmembers operation" exit(0) gm = GroupManager() res = gm.list_members(args[1]) if res==-1: print "Group does not exist"