def execute(self): userid=capture("whoami").rstrip() host=syshost() if (host=="stampede" or host=="ls5"): spaces=["/home1","/work"] elif host=="ls4": spaces=["/home1","/work"] elif (host=="maverick"): spaces=["/home","/work"] else: return True Flag=True for space in spaces: if ( (host=="ls4" and space=="/home1") or (host=="maverick" and space=="/home") or (host=="ls5" and space=="/home1")): quotacmd="quota" rawinfo=capture(quotacmd).split("\n") if len(rawinfo)<3: return False quotainfo=rawinfo[-2].split() ## print(quotainfo[0],quotainfo[2],quotainfo[3],quotainfo[5]) ## print(quotainfo) ## if len(quotainfo) <6: if len(quotainfo) <6 or (not (quotainfo[0]).isdigit()): self.error_message+="\tError: "+"No valid quota report\n" return False if float(quotainfo[0]) >= float(quotainfo[2])*0.95 : Flag=False self.error_message+="\tError: You are over/close to the disk limit under %s.\n" %space if float(quotainfo[3]) >= float(quotainfo[5])*0.95 : Flag=False self.error_message+="\tError: You are over/close to the inode limit under %s.\n" %space else: lfscmd="lfs quota -u %s %s" %(userid,space) ## print(lfscmd) quotainfo=capture(lfscmd).split("\n")[2].split() quotainfo[5]=quotainfo[5].strip("*") quotainfo[1]=quotainfo[1].strip("*") ## print(quotainfo[1], quotainfo[3], quotainfo[5], quotainfo[7] ## print(quotainfo) if len(quotainfo) <8: self.error_message+="\tError: "+"No valid quota report\n" return False if float(quotainfo[1]) >= float(quotainfo[3])*0.95 : Flag=False self.error_message+="\tError: You are over/close to the disk limit under %s.\n" %space if float(quotainfo[5]) >= float(quotainfo[7])*0.95 : Flag=False self.error_message+="\tError: Your are over/close to the inode limit under %s.\n" %space return Flag
def execute(self): userid=capture("whoami").rstrip() host=syshost() if (host=="stampede2" or host=="ls5"): spaces=["/home1","/work"] elif host=="ls4": spaces=["/home1","/work"] elif (host=="maverick"): spaces=["/home","/work"] else: return True Flag=True for space in spaces: if ( (host=="ls4" and space=="/home1") or (host=="maverick" and space=="/home") or (host=="ls5" and space=="/home1")): quotacmd="quota" rawinfo=capture(quotacmd).split("\n") if len(rawinfo)<3: return False quotainfo=rawinfo[-2].split() ## print(quotainfo[0],quotainfo[2],quotainfo[3],quotainfo[5]) ## print(quotainfo) if len(quotainfo) <6 or (not (quotainfo[0]).isdigit()): self.error_message+="\tError: "+"No valid quota report\n" return False if float(quotainfo[0]) >= float(quotainfo[2])*0.9 : Flag=False self.error_message+="\tError: You are over/close to the disk limit under %s.\n" %space if float(quotainfo[3]) >= float(quotainfo[5])*0.9 : Flag=False self.error_message+="\tError: You are over/close to the inode limit under %s.\n" %space else: lfscmd="lfs quota -u %s %s" %(userid,space) ## print(lfscmd) quotainfo=capture(lfscmd).split("\n")[2].split() quotainfo[5]=quotainfo[5].strip("*") quotainfo[1]=quotainfo[1].strip("*") ## print(quotainfo[1], quotainfo[3], quotainfo[5], quotainfo[7] ## print(quotainfo) if len(quotainfo) <8: self.error_message+="\tError: "+"No valid quota report\n" return False if float(quotainfo[1]) >= float(quotainfo[3])*0.85 : Flag=False self.error_message+="\tError: You are over/close to the disk limit under %s.\n" %space if float(quotainfo[5]) >= float(quotainfo[7])*0.85 : Flag=False self.error_message+="\tError: Your are over/close to the inode limit under %s.\n" %space return Flag
def execute(self): # Different variable are necessary on different machines. standardVarT = { 'kingspeak': ["HOME", "UUFSCELL"], 'notchpeak': ["HOME"], 'lonepeak': ["HOME"], 'redwood': ["HOME"], 'ember': ["HOME"], 'ash': ["HOME"], 'frisco': ["HOME"], } host = syshost() #print(host) if host in standardVarT.keys(): varA = standardVarT.get(host, standardVarT[host]) else: self.error_message += "Not a known host." result = False return if not varA: return True result = True unknown = "**UNKNOWN**" for var in varA: value = os.environ.get(var, unknown) if (value == unknown): temp_string = "\tError: Your $" + var + " is not defined.\n" self.error_message += temp_string result = False elif (os.path.exists(value)): pass else: if var != "UUFSCELL": temp_string = "\tError: Your $" + var + " space(" + value + ") is not accessible at this time!\n" self.error_message += temp_string result = False # fake test, ignore in the practical runs # mypath="/home/01225/siliu/no_exist_dir/" # if (os.path.exists(mypath) ): # print("my path exists") # else: # print("my path does not exist") return result
def execute(self): # Different variable are necessary on different machines. standardVarT = { 'stampede': ["HOME", "WORK", "STOCKYARD", "SCRATCH"], 'stampede2': ["HOME", "WORK", "STOCKYARD", "SCRATCH"], 'ls4': ["HOME", "WORK", "SCRATCH"], 'maverick': ["HOME", "WORK", "STOCKYARD"], 'maverick2': ["HOME", "WORK"], 'frontera': ["HOME", "WORK", "SCRATCH"] } host = syshost() if host in standardVarT.keys(): varA = standardVarT.get(host, standardVarT[host]) else: self.error_message += "Not a known host." result = False return if not varA: return True result = True unknown = "**UNKNOWN**" for var in varA: value = os.environ.get(var, unknown) if (value == unknown): temp_string = " ERROR: Your $" + var + " is not defined.\n" self.error_message += temp_string result = False elif (os.path.exists(value)): pass else: temp_string = " ERROR: Your $" + var + " space(" + value + ") is not accessible at this time!\n" self.error_message += temp_string result = False # fake test, ignore in the practical runs # mypath="/home/01225/siliu/no_exist_dir/" # if (os.path.exists(mypath) ): # print("my path exists") # else: # print("my path does not exist") return result
def execute(self): host = syshost() if (host == "stampede" or host == "maverick" or host == "ls5"): commands = ["sbatch", "squeue", "scancel", "scontrol"] elif host == "ls4": commands = ["qsub", "qstat", "qdel"] else: return True Flag = True for command1 in commands: typecmd = "type %s" % command1 output = capture(typecmd) if "not found" in output: Flag = False self.error_message += "\tError: Scheduler command \"%s\" is not available at this time!\n" % command1 return Flag
def execute(self): host=syshost() if host=="stampede": commands=["sbatch","squeue","scancel"] elif host=="ls4": commands=["qsub","qstat","qdel"] else: return True Flag=True for command1 in commands: typecmd="type %s" %command1 output=capture(typecmd) if "not found" in output: Flag=False self.error_message+=" Error: Scheduler command \"%s\" is not available now!\n" %command1 return Flag
def execute(self): host=syshost() if host=="stampede": commands=["sbatch","squeue","scancel"] elif host=="ls4": commands=["qsub","qstat","qdel"] else: return True Flag=True for command1 in commands: typecmd="type %s" %command1 output=capture(typecmd) if "not found" in output: Flag=False self.error_message+=" ERROR: Scheduler command \"%s\" is not available now!\n" %command1 return Flag
def execute(self): # Different variable are necessary on different machines. standardVarT = { 'stampede' : [ "HOME", "WORK", "STOCKYARD", "SCRATCH" ], 'ls4' : [ "HOME", "WORK", "SCRATCH" ], 'ls5' : [ "HOME", "WORK", "STOCKYARD", "SCRATCH" ], 'maverick' : [ "HOME", "WORK", "STOCKYARD" ], } host = syshost() if host in standardVarT.keys(): varA = standardVarT.get(host, standardVarT[host]) else: self.error_message+="Not a known host." result = False return if not varA: return True result = True unknown = "**UNKNOWN**" for var in varA: value = os.environ.get(var,unknown) if (value == unknown): temp_string="\tError: Your $"+var+" is not defined.\n" self.error_message+=temp_string result = False elif( os.path.exists(value) ): pass else: temp_string="\tError: Your $" + var + " space(" + value + ") is not accessible at this time!\n" self.error_message+=temp_string result=False # fake test, ignore in the practical runs # mypath="/home/01225/siliu/no_exist_dir/" # if (os.path.exists(mypath) ): # print("my path exists") # else: # print("my path does not exist") return result
def execute(self): host = syshost() if host!="stampede" and host!="frontera": return True userid=getpass.getuser() grepcmd1="""awk '/ALL = /,/ALL = /' /etc/slurm/tacc_filter_options | awk '{print substr($0,7,length($0)-7)}' | awk -v user=%s 'BEGIN {FS=" !!"}; {for (i=1; i<=NF; i++) if($i == user) {print $0}}'""" %userid # print(grepcmd1) myrecord1=capture(grepcmd1).split('\n') # print(myrecord1) grepcmd2="""awk '($1=="largemem")' /etc/slurm/tacc_filter_options | awk '{gsub(/ /, "", $0);print substr($0,12, length($0)-12)}' | awk -v user=%s 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'""" %userid # print(grepcmd2) myrecord2=capture(grepcmd2).split('\n') # print(myrecord2) # grepcmd3="""awk '($1=="normal-mic" || $1=="normal-2mic")' /etc/slurm/tacc_filter_options | awk '{gsub(/ /, "", $0); print substr($0,14, length($0)-14)}' | awk -v user=%s 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'""" %userid # print(grepcmd3) # myrecord3=capture(grepcmd3).split('\n') # print(myrecord3) myrecord=myrecord1 + myrecord2 # print(myrecord) for ss in myrecord1: if ss and not ss.strip().startswith('#'): self.error_message+=" ERROR: You are blocked from general submission.\n" return False for ss in myrecord2: if ss and not ss.strip().startswith('#'): self.error_message+=" ERROR: You are blocked from largemem queue submission.\n" return False # for ss in myrecord3: # if ss and not ss.strip().startswith('#'): # self.error_message+=" ERROR: You are blocked from mic queue submission.\n" # return False return True
def execute(self): host = syshost() if host!="stampede": return True userid=capture("whoami").rstrip() grepcmd1="""awk '/ALL = /,/ALL = /' /etc/slurm/tacc_filter_options | awk '{print substr($0,7,length($0)-7)}' | awk -v user=%s 'BEGIN {FS=" !!"}; {for (i=1; i<=NF; i++) if($i == user) {print $0}}'""" %userid # print(grepcmd1) myrecord1=capture(grepcmd1).split('\n') # print(myrecord1) grepcmd2="""awk '($1=="largemem")' /etc/slurm/tacc_filter_options | awk '{gsub(/ /, "", $0);print substr($0,12, length($0)-12)}' | awk -v user=%s 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'""" %userid # print(grepcmd2) myrecord2=capture(grepcmd2).split('\n') # print(myrecord2) grepcmd3="""awk '($1=="normal-mic" || $1=="normal-2mic")' /etc/slurm/tacc_filter_options | awk '{gsub(/ /, "", $0); print substr($0,14, length($0)-14)}' | awk -v user=%s 'BEGIN {FS="!!"}; {for (i=1; i<=NF; i++) if ($i == user) {print $0}}'""" %userid # print(grepcmd3) myrecord3=capture(grepcmd3).split('\n') # print(myrecord3) myrecord=myrecord1 + myrecord2 + myrecord3 # print(myrecord) for ss in myrecord1: if ss and not ss.strip().startswith('#'): self.error_message+="\tError: You are blocked from general submission.\n" return False for ss in myrecord2: if ss and not ss.strip().startswith('#'): self.error_message+="\tError: You are blocked from largemem queue submission.\n" return False for ss in myrecord3: if ss and not ss.strip().startswith('#'): self.error_message+="\tError: You are blocked from mic queue submission.\n" return False return True
def execute(self): userid=capture("whoami").rstrip() ### userid="jkatzene" #Fake test host=syshost() if (host=="stampede" or host=="maverick" or host=="ls5"): TACC_ACC_DIR="/usr/local/etc/" elif host=="ls4": TACC_ACC_DIR="/sge_common/default/acct/map/" else: return True proj_map=TACC_ACC_DIR+"project.map" projuser_map=TACC_ACC_DIR+"projectuser.map" projbalance_map=TACC_ACC_DIR+"projectbalance.map" usage_map=TACC_ACC_DIR+"usage.map" # grepcmd="grep %s %s" %(userid,projuser_map) grepcmd="""awk -v user=%s '$1 == user {print $0}' %s """ %(userid,projuser_map) # print(grepcmd) myprojects=capture(grepcmd).split() # print(myprojects) if len(myprojects) < 2: self.error_message+="\tError: "+"No valid allocation\n" return False Flag=False for proj in myprojects[1:]: grepcmd="grep %s$ %s" %(proj,proj_map) # print(grepcmd) proj_name_all=capture(grepcmd).split() # print(proj_name_all) if proj_name_all: proj_name=proj_name_all[0] # grepcmd="grep %s %s" %(proj_name,usage_map) grepcmd="awk -F: '{ if ($1==\"%s\") print}' %s" %(proj_name,usage_map) # print(grepcmd) # print(capture(grepcmd)) usage_report=capture(grepcmd).split(":") if len(usage_report) < 6: print("\033[1;33m\tWarning: Valid allocation detected.\033[0m") continue exp_date=usage_report[3].split("-") exp_date_f=date(int(exp_date[0]), int(exp_date[1]), int(exp_date[2])) today = date.today() cur_bal=float(usage_report[6]) # print(" My project '%s'; balance %s." %(proj_name,cur_bal)) if exp_date_f < date.today(): print("\033[1;33m\tWarning: One of your projects '%s' has expired.\033[0m" %proj_name[0]) elif cur_bal < 0: print("\033[1;33m\tWarning: One of your projects '%s' has negative balance %s.\033[0m" %(proj_name,cur_bal)) else: Flag=True if Flag: return True else: self.error_message+="\tError: All your allocations are invalid" return Flag
def diskquota(): # primitive argument input for userid - no error checking if len(sys.argv) == 2: userid = sys.argv[1] else: userid = capture("whoami").rstrip() #userid="u6006455" host = syshost() grepcmd1 = "curl --data 'unid={0}' https://www.chpc.utah.edu/apps/systems/curl_post/CHPCUserQuota.php -k -s | tail -n +2".format( userid) myfs = capture(grepcmd1).splitlines() goodcolor = "32m" badcolor = "31m" for space in myfs: #print(space) # if ( (host=="ls4" and space=="/home1") or (host=="maverick" and space=="/home") or (host=="ls5" and space=="/home1")): rawinfo = space.split("\t") #print(rawinfo) if (rawinfo[0] == userid) or (userid in rawinfo[0]): usage = rawinfo[1][:-4] files = rawinfo[3] quota = rawinfo[2][:-1] if rawinfo[0] == userid: fsuse = rawinfo[5][:-4] fsmax = rawinfo[6][:-1] #if ((fsmax != 0) and (float(fsuse)/float(fsmax) > 0.9)): if (isinstance(fsuse, int) and isinstance(fsmax, int)): if (float(fsuse) / float(fsmax) > 0.9): fscolor = badcolor else: fscolor = goodcolor if quota == "0": badusage = 100 else: badusage = int(quota) if float(usage) > badusage: ucolor = badcolor umsg = "\033[1;31mare over the quota limit\033[0m" else: ucolor = goodcolor umsg = "have quota limit" if int(files) > 100000: fcolor = badcolor else: fcolor = goodcolor if rawinfo[0] == userid: if (rawinfo[2] == "0G"): if (files == 0): print( "\tIn \033[1;36m{0}\033[0m you have no quota limit, use \033[1;{2}{1} GB\033[0m" .format("General Home Directory", usage, ucolor)) else: print( "\tIn \033[1;36m{0}\033[0m you have no quota limit, use \033[1;{3}{1} GB\033[0m and have \033[1;{4}{2}\033[0m files" .format("General Home Directory", usage, files, ucolor, fcolor)) if (fsuse != 0): print( "\t (total file system usage is \033[1;{2}{0} GB\033[0m out of \033[1;{2}{1} GB\033[0m)" .format(fsuse, fsmax, fscolor)) #print("\tOn \033[1;36m{0}\033[0m you have no quota limit, use \033[1;{3}{1} GB\033[0m (total file system usage is {5} GB out of {6} GB) and have \033[1;{4}{2}\033[0m files".format(rawinfo[0],usage,files,ucolor,fcolor,fsuse,fsmax)) else: if (files == '0'): print( "\tIn \033[1;36m{0}\033[0m you {4} \033[1;{3}{2} GB\033[0m and use \033[1;{3}{1} GB\033[0m" .format("General home directory", usage, quota, ucolor, umsg)) else: print( "\tIn \033[1;36m{0}\033[0m you {6} \033[1;{4}{3} GB\033[0m, use \033[1;{4}{1} GB\033[0m and have \033[1;{5}{2}\033[0m files" .format("General home directory", usage, files, quota, ucolor, fcolor, umsg)) if (fsuse != '0'): print( "\t (total file system usage is \033[1;{2}{0} GB\033[0m out of \033[1;{2}{1} GB\033[0m)" .format(fsuse, fsmax, fscolor)) else: print( "\tIn \033[1;36m{0}\033[0m you {6} \033[1;{7}{3} GB\033[0m, use \033[1;{4}{1} GB\033[0m and have \033[1;{5}{2}\033[0m files" .format("PE Home Directory", usage, files, quota, ucolor, fcolor, umsg, ucolor))
def allocations(): host = syshost() #print(host) if (host!="kingspeak")and(host!="ember")and(host!="lonepeak")and(host!="notchpeak")and(host!="ash")and(host!="redwood")and(host!="crystalpeak"): print("This command needs to run on one of the CHPC clusters") sys.exit(1) # primitive argument input for userid - no error checking if len(sys.argv)==2: userid=sys.argv[1] else: userid=capture("whoami").rstrip() #userid="u1119546" #userid="u0631741" # redwood tests #userid="u6000771" #userid="u0413537" #userid="u6002243" # MC Jan 20 # potentially cleaner version may be to create a list of account-QOS associations with sacctmgr # and then compare QOS from each of the association to the "scontrol -o show partition" output to get the corresponding partition # the scontrol can be run only once with result stored in an array so that it's not run repeatedly # sacctmgr -p show qos lists what QOSes can this one preempt (Preempt = column 4), can see if preemptable QOS is in this output which would mean that it's preemptable grepcmd1="sacctmgr -n -p show assoc where user={0}".format(userid) #print(grepcmd1) myaccts=capture(grepcmd1).split() #print(myaccts,len(myaccts)) if host=="redwood": clusters=["redwood"] elif host=="crystalpeak": clusters=["crystalpeak"] else: clusters=["kingspeak","notchpeak","lonepeak","ash"] for cluster in clusters: FCFlag=True if cluster=="kingspeak": cl="kp" elif cluster=="notchpeak": cl="np" elif cluster=="ember": cl="em" elif cluster=="lonepeak": cl="lp" elif cluster=="ash": cl="smithp-ash" elif cluster=="redwood": cl="rw" elif cluster=="crystalpeak": cl="cp" matchcl = [s for s in myaccts if cluster in s] #print(matchcl, len(matchcl)) if len(matchcl) > 0: if (len(matchcl) > 1): # first filter out owner accounts # this will be true if there are owner nodes matchstr="^((?!-{0}).)*$".format(cl) #print(matchstr) r=re.compile(matchstr) matchcl = list(filter(r.match, matchcl)) #print(matchcl) #print("Error, more than 1 match: {0}".format(matchcl)) # now filter out the freecycle accounts matchfc = [s for s in matchcl if "freecycle" in s] if len(matchfc) > 0: #print(matchfc) for matchfc0 in matchfc: pnames=matchfc0.split('|') #print(pnames) print("\tYour group \033[1;31m{0}\033[0m does not have a \033[1;36mgeneral\033[0m allocation on \033[1;34m{1}\033[0m".format(pnames[1],cluster)) print("\tYou can use \033[1;33mpreemptable\033[0m mode on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],pnames[17])) print("\tYou can use \033[1;33mpreemptable\033[0m mode on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],cluster+"-shared-freecycle")) # now look at allocated group accounts - so need to exclude owner-guest and freecycle matchg1 = [s for s in matchcl if not "freecycle" in s] #print(matchg1) matchg2 = [s for s in matchg1 if not "guest" in s] matchg3 = [s for s in matchg2 if not "collab" in s] # also filter out gpu accounts matchg4 = [s for s in matchg3 if not "gpu" in s] #matchg = [s for s in matchg2 if not "shared-short" in s] matchg = [s for s in matchg4 if not "notchpeak-shared" in s] if len(matchg)>0: #print(matchg) for matchg1 in matchg: #print(matchg1) myrecord1 = matchg1.split('|') #print(myrecord1) print("\tYou have a \033[1;36mgeneral\033[0m allocation on \033[1;34m{1}\033[0m. Account: \033[1;32m{0}\033[0m, Partition: \033[1;32m{2}\033[0m".format(myrecord1[1],cluster,myrecord1[18])) if (myrecord1[1] != "dtn"): # account dtn that matches here does not have shared partition print("\tYou have a \033[1;36mgeneral\033[0m allocation on \033[1;34m{1}\033[0m. Account: \033[1;32m{0}\033[0m, Partition: \033[1;32m{2}\033[0m".format(myrecord1[1],cluster,cluster+"-shared")) # shared-short matchgrp = [s for s in myaccts if "shared-short" in s] matchcl = [s for s in matchgrp if cluster in s] if len(matchcl) > 0: matchstr="^((?!{0}).)*$".format(cl) r=re.compile(matchstr) matchcl = list(filter(r.match, matchcl)) pnames=matchcl[0].split('|') print("\tYou have a \033[1;36mgeneral\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{1}\033[0m".format(cluster,pnames[1])) # owner accounts grepcmd1="sacctmgr -p show assoc where user={0} | grep {1} | grep -w {2} | grep -v guest".format(userid,cluster,cl) # need to grep out guest since for ash cl=smithp-ash #print(grepcmd1) myprojects=capture(grepcmd1).split() #print(myprojects,len(myprojects)) if len(myprojects) > 0: for project in myprojects: pnames=project.split('|') #print(pnames) # MC 1/24/20 - using scontrol to grep for partition that corresponds to the QOS in pnames[18] # example user that had QOS vs partition mix up - u6022494 qosname = pnames[18] # in case "Def QOS" = pnames[18] is not defined, try "QOS" = pnames[17] if len(pnames[18]) == 0: qosname = pnames[17] grepcmd2="scontrol -M {1} -o show partition | grep {0} | grep -v shared".format(qosname,cluster) #print(grepcmd2) myparts=capture(grepcmd2).split() if len(myparts) > 0: #print(myparts,len(myparts)) #print(myparts[0]) mypart=myparts[0].split('=') #print(mypart[1]) pgroup=mypart[1].split('-') print("\tYou have an \033[1;36mowner\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],mypart[1])) print("\tYou have an \033[1;36mowner\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],pgroup[0]+"-shared-"+pgroup[1])) else: print("\t\033[1;31mError:\033[0m you are in QOS \033[1;34m{0}\033[0m, but partition \033[1;32m{0}\033[0m does not exist. Please contact CHPC to fix this.".format(qosname)) # collab accounts grepcmd1="sacctmgr -p show assoc where user={0} | grep {1} | grep -w {2} | grep -v guest".format(userid,cluster,"collab") # need to grep out guest since for ash cl=smithp-ash #print(grepcmd1) myprojects=capture(grepcmd1).split() #print(myprojects,len(myprojects)) if len(myprojects) > 0: for project in myprojects: pnames=project.split('|') pgroup=pnames[17].split('-') #print(pnames) print("\tYou have an \033[1;36mowner\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],pgroup[0]+"-"+cl)) print("\tYou have an \033[1;36mowner\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],pgroup[0]+"-shared-"+cl)) # owner guest # have to get matchcl again since we may have changed it above matchcl = [s for s in myaccts if cluster in s] matchstr=".*\\bguest\\.*" #print(matchstr) #print(matchcl, len(matchcl)) r=re.compile(matchstr) myprojects = list(filter(r.match, matchcl)) #print(myprojects) if len(myprojects) > 0: for project in myprojects: if "gpu" in project: gpustr = " GPU" else: gpustr = "" pnames=project.split('|') part=pnames[17].split(',') # #print(pnames) print("\tYou can use \033[1;33mpreemptable{3}\033[0m mode on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],part[0],gpustr)) # GPU accounts grepcmd1="sacctmgr -p show assoc where user={0} | grep {1} | grep -w gpu | grep -v guest".format(userid,cluster) #print(grepcmd1) myprojects=capture(grepcmd1).split() if len(myprojects) > 0: for project in myprojects: pnames=project.split('|') #print(pnames) print("\tYou have a \033[1;36mGPU\033[0m allocation on \033[1;34m{0}\033[0m. Account: \033[1;32m{1}\033[0m, Partition: \033[1;32m{2}\033[0m".format(cluster,pnames[1],pnames[17]))