Added option --excluldeusers ignoring users based on a given regular expression.
This commit is contained in:
parent
de52f45532
commit
64d5da9924
1 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,7 @@ parser.add_option("--startdate", metavar="YYYY-MM-DD", dest="startdate")
|
|||
parser.add_option("--enddate", metavar="YYYY-MM-DD", dest="enddate")
|
||||
parser.add_option("--nohpc", action="store_true", default=False, dest="nohpc", help="Exclude hpc* accounts from stats")
|
||||
parser.add_option("--printusers", action="store_true", default=False, dest="printusers", help="Print detailed user lists for module usage.")
|
||||
parser.add_option("--excludeusers", metavar="REGEX", dest="excludeusers", help="Exclude users mathich given regular expression")
|
||||
parser.add_option("--list-unused", action="store_true", default=False, dest="list_unused", help="List only unused modules.")
|
||||
(options, args) = parser.parse_args()
|
||||
if options.logdir :
|
||||
|
@ -39,6 +40,8 @@ if options.enddate :
|
|||
enddate = datetime.date(int(d[0:4]),int(d[5:7]),int(d[8:10]))
|
||||
if len(args) > 0 :
|
||||
modulepattern = args[0]
|
||||
if options.excludeusers :
|
||||
excludeusers_re = re.compile(str(options.excludeusers))
|
||||
|
||||
|
||||
for logfilename in os.listdir(logdir) :
|
||||
|
@ -56,6 +59,8 @@ for logfilename in os.listdir(logdir) :
|
|||
user = line.split()[-3][5:] # remove user: in front
|
||||
if options.nohpc and 'hpc' in user :
|
||||
continue
|
||||
if options.excludeusers and excludeusers_re.match(user):
|
||||
continue
|
||||
total_users.add(user)
|
||||
total_modules = total_modules + 1
|
||||
if module not in modules:
|
||||
|
|
Loading…
Reference in a new issue