# Task: identify groups that have obsolete 'user' entries. from readp4marshal import runp4cmd import os # # num of calls to 'p4': 2 # status: tested on Darwin Mac OS X using Python 2.3 # room for optimization/improvement: add getopts call # userlist = {} #----------------------------------------------------------- # first call to P4: 'p4 users' #----------------------------------------------------------- userout = runp4cmd("p4 -G users") for u in userout: userid = u['User'] userlist[userid] = u # save the entry #----------------------------------------------------------- # second call to P4: 'p4 groups' (2004.2 and later output) #----------------------------------------------------------- groupsout = runp4cmd("p4 -G groups") for g in groupsout: userid = g['user'] groupid = g['group'] if not userlist.has_key(userid): print "User %s is in group %s (invalid user)" % (userid, groupid)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 4889 | Jeff Bowles |
simple example of group-auditing script to notice groups that reference users that don't exist in 'p4 users' |