本文整理汇总了Python中ProgressBar.ProgressBar.finish方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.finish方法的具体用法?Python ProgressBar.finish怎么用?Python ProgressBar.finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.finish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PrintDailyMetrics
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def PrintDailyMetrics(self):
prog = ProgressBar(0, 100, 77)
indmetrics = self.cinfo.metorder.keys()
indmetrics.sort()
sites = self.matrices.columnValues.keys()
sites.sort()
for sitename in sites:
prog.increment(100./3.)
dates = self.matrices.dailyMetrics[sitename].keys()
dates.sort()
for dat in dates:
if self.SkipSiteOutput(sitename): continue
for metnumber in indmetrics:
met = self.cinfo.metorder[metnumber] #colName
met1 = self.cinfo.printCol[met] #pCol (print permission)
#if not self.matrices.columnValues[sitename][dat].has_key(met) or met == 'IsSiteInSiteDB': continue # ignore
if not self.matrices.columnValues[sitename][dat].has_key(met) or met1 == '0' : continue # ignore
if self.matrices.columnValues[sitename][dat][met].has_key('URL'):
url = self.matrices.columnValues[sitename][dat][met]['URL']
else:
url = "-"
print dat, sitename, met, self.matrices.columnValues[sitename][dat][met]['Status'], self.matrices.columnValues[sitename][dat][met]['Color'],url
prog.finish()
示例2: ProduceSiteReadinessSSBFiles
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def ProduceSiteReadinessSSBFiles(self):
print "\nProducing Site Readiness SSB files to commission view\n"
prog = ProgressBar(0, 100, 77)
for dayspan in 30, 15, 7:
prog.increment(100./3.)
fileSSBRanking = self.ssbOutDir + '/SiteReadinessRanking_SSBfeed_last' + str(dayspan) + 'days.txt'
fileHandle = open ( fileSSBRanking , 'w' )
sitesit = self.matrices.readiValues.keys()
sitesit.sort()
for sitename in sitesit:
if self.SkipSiteOutput(sitename): continue
pl = "R+Wcorr_perc"
color = "red"
if sitename.find("T1") == 0 and self.matrices.stats[sitename][dayspan][pl]>90:
color="green"
if sitename.find("T2") == 0 and self.matrices.stats[sitename][dayspan][pl]>80:
color="green"
if self.matrices.stats[sitename][dayspan][pl] != "n/a":
filenameSSB = self.options.url + "/SiteReadiness/PLOTS/" + sitename.split("_")[0] + "_" + pl + "_last" + str(dayspan) + "days_" + self.tinfo.timestamphtml + ".png"
tofile = self.tinfo.todaystampfileSSB + '\t' + sitename + '\t' + str(self.matrices.stats[sitename][dayspan][pl]) + '\t' + color + '\t' + filenameSSB + "\n"
fileHandle.write(tofile)
fileHandle.close()
prog.finish()
示例3: ProduceSiteReadinessSSBFile
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def ProduceSiteReadinessSSBFile(self):
print "\nProducing Site Readiness SSB input file\n"
prog = ProgressBar(0, 100, 77)
fileHandle = open(self.fileSSB, "w")
sitesit = self.matrices.readiValues.keys()
sitesit.sort()
for sitename in sitesit:
prog.increment(100.0 / len(sitesit))
if self.SkipSiteOutput(sitename):
continue
status = self.matrices.readiValues[sitename][self.tinfo.yesterdaystamp]
colorst = self.SRMatrixColors[status]
linkSSB = self.options.url + "/SiteReadiness/HTML/SiteReadinessReport_" + self.tinfo.timestamphtml + ".html"
tofile = (
self.tinfo.todaystampfileSSB
+ "\t"
+ sitename
+ "\t"
+ status
+ "\t"
+ colorst
+ "\t"
+ linkSSB
+ "#"
+ sitename
+ "\n"
)
fileHandle.write(tofile)
fileHandle.close()
prog.finish()
示例4: PrintDailyMetricsStats
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def PrintDailyMetricsStats(self):
print "\nPrinting Daily Metrics Statistics\n"
prog = ProgressBar(0, 100, 77)
fileHandle = open(self.asciiOutDir + "/Daily_HistoricStatistics.txt", "w")
sites = self.matrices.dailyMetrics.keys()
sites.sort()
for sitename in sites:
dates = self.matrices.dailyMetrics[sitename].keys()
dates.sort()
continue
for i in "T1", "T2":
prog.increment(100.0 / 2.0)
for dat in dates:
countO = 0
countE = 0
countSD = 0
countna = 0
for sitename in sites:
if sitename.find("T1_CH_CERN") == 0:
continue
if not sitename.find(i + "_") == 0:
continue
if self.SkipSiteOutput(sitename):
continue
state = self.matrices.dailyMetrics[sitename][dat]
if state == "O":
countO += 1
if state == "E":
countE += 1
if state.find("n/a") == 0:
countna += 1
if state == "SD":
countSD += 1
if dat == self.tinfo.todaystamp:
continue
tofile = (
"Daily Metric "
+ i
+ " "
+ dat
+ " "
+ str(countE)
+ " "
+ str(countO)
+ " "
+ str(countna)
+ " "
+ str(countSD)
+ " "
+ str(countE + countO + countSD + countna)
+ "\n"
)
fileHandle.write(tofile)
fileHandle.close()
prog.finish()
示例5: ParseXML
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def ParseXML(self):
print "\nObtaining XML info from SSB 'Site Readiness' view\n"
prog = ProgressBar(0, 100, 77)
xmlCacheDir = self.options.path_out + "/INPUTxmls"
if not os.path.exists(xmlCacheDir):
os.makedirs(xmlCacheDir)
ColumnItems = self.cinfo.urls.keys()
ColumnItems.sort()
for col in ColumnItems:
prog.increment(100./len(ColumnItems))
url = self.cinfo.urls[col]
xmlFile = xmlCacheDir + "/" + col + ".xml"
if self.options.xml == 'false' and not os.path.exists(xmlCacheDir):
print "\nWARNING: you cannot re-use the XML files as the files were not obtained before. Obtaining them...\n"
self.options.xml = 'true'
if self.options.xml == 'true': # download xml file if requested
print "Column %s - Getting the url %s" % (col, url)
os.system("curl -s -H 'Accept: text/xml' '%s' > %s" % (url,xmlFile))
f = file(xmlFile,'r') # read xml file that was either just written, or was written in the previous run
t = xml.dom.minidom.parse(f)
f.close()
#print t.toprettyxml()
for subUrl in xpath.Evaluate("/getplotdata/csvdata/item", t):
#print subUrl.toprettyxml()
info = {} # basic info about the site for this column
for option in ('Status', "COLOR", 'Time', 'EndTime','VOName','URL'):
for target in xpath.Evaluate(option, subUrl):
if target.hasChildNodes():
s = target.firstChild.nodeValue.encode('ascii')
else:
s = ""
info[option] = s
voname = info['VOName']
time = info['Time']
xmlMatrix = self.matrices.xmlInfo
if self.options.oneSite != "" and voname.find(self.options.oneSite) != 0: continue
if not xmlMatrix.has_key(voname): # if site not already in dict, add an empty dict for it
xmlMatrix[voname] = {}
if not xmlMatrix[voname].has_key(col): # if site entry doesn't already have this column, add an empty dict for this column
xmlMatrix[voname][col] = {}
xmlMatrix[voname][col][time] = info # set the actual values
# Correct some of the strings
value = xmlMatrix[voname][col][time]['Status']
if col=="HammerCloud" and value != "n/a":
value = str(int(float(value)))
if value.find("%") != 0:
value += "%"
elif col=="SUMAvailability":
value = str(int(round(float(value))))
if value.find("%") != 0:
value += "%"
xmlMatrix[voname][col][time]['Status'] = value
prog.finish()
示例6: ProduceSiteReadinessStatistics
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def ProduceSiteReadinessStatistics(self):
print "\nProducing Site Readiness Statistics\n"
sitesit = self.matrices.readiValues.keys()
sitesit.sort()
prog = ProgressBar(0, 100, 77)
for dayspan in 30, 15, 7:
prog.increment(100./3.)
for sitename in sitesit:
if self.SkipSiteOutput(sitename): continue
countR = 0; countW = 0; countNR = 0; countSD = 0; countNA = 0
infostats2 = {}
if not self.matrices.stats.has_key(sitename):
self.matrices.stats[sitename]={}
for i in range(0,dayspan):
deltaT = datetime.timedelta(i)
datestamp = self.tinfo.yesterday - deltaT
state = self.matrices.readiValues[sitename][datestamp.strftime("%Y-%m-%d")]
if state == "R": countR += 1
if state == "W": countW += 1
if state == "NR": countNR += 1
if state == "SD": countSD += 1
if state.find("n/a") == 0: countNA += 1
if not self.matrices.stats[sitename].has_key(dayspan):
self.matrices.stats[sitename][dayspan]={}
infostats2['R_perc']= (int)(round(100.*countR/dayspan))
infostats2['W_perc']= (int)(round(100.*countW/dayspan))
infostats2['R+W_perc']= (int)(round(100.*(countR+countW)/dayspan))
infostats2['NR_perc']= (int)(round(100.*countNR/dayspan))
infostats2['SD_perc']= (int)(round(100.*countSD/dayspan))
infostats2['R']= countR
infostats2['W']= countW
infostats2['R+W']= countW+countR
infostats2['NR']= countNR
infostats2['SD']= countSD
infostats2['days']=dayspan
if (dayspan-countSD-countNA)!=0:
infostats2['Rcorr_perc']= (int)(round(100.*countR/(dayspan-countSD-countNA)))
infostats2['Wcorr_perc']= (int)(round(100.*countW/(dayspan-countSD-countNA)))
infostats2['R+Wcorr_perc']= (int)(round(100.*(countR+countW)/(dayspan-countSD-countNA)))
infostats2['NRcorr_perc']= (int)(round(100.*countNR/(dayspan-countSD-countNA)))
else:
infostats2['Rcorr_perc']= 0
infostats2['Wcorr_perc']= 0
infostats2['R+Wcorr_perc']= 0
infostats2['NRcorr_perc']= 100
self.matrices.stats[sitename][dayspan]=infostats2
prog.finish()
示例7: __init__
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
class progressBar:
def __init__(self, title, indeterminate=False, gui=False):
self.indeterminate = indeterminate
osxgui = False
self.bar = None
if sys.platform == 'darwin':
osxgui = gui
if osxgui:
try:
self.bar = ProgressBar(title=title, indeterminate=indeterminate)
except:
pass
# oh well, no CocoaDialog probably
self.reset(title, indeterminate=indeterminate)
self.update('', 0) # Build progress bar string
def reset(self, title, indeterminate=False):
if indeterminate != self.indeterminate:
if self.bar: self.bar.finish()
self.indeterminate = indeterminate
if self.bar:
self.bar = ProgressBar(title=title, indeterminate=indeterminate)
self.progBar = "[]" # This holds the progress bar string
self.width = 40
self.amount = 0 # When amount == max, we are 100% done
def finish(self):
if self.bar: self.bar.finish()
def update(self, message='', fraction=0.0, after_args=()):
self.message = message
# Figure out how many hash bars the percentage should be
allFull = self.width - 2
percentDone = int(round(fraction*100))
numHashes = int(round(fraction * allFull))
# build a progress bar with hashes and spaces
self.progBar = "[" + '#'*numHashes + ' '*(allFull-numHashes) + "]"
# figure out where to put the percentage, roughly centered
percentPlace = (len(self.progBar) / 2) - len(str(percentDone))
percentString = ' '+ str(percentDone) + r"% "
# slice the percentage into the bar
self.progBar = self.progBar[0:percentPlace] + percentString + \
self.progBar[percentPlace+len(percentString):]
if self.bar: self.bar.update(percentDone, message)
if self.indeterminate:
sys.stdout.write(self.message + ' '.join(after_args) + '\r')
else:
sys.stdout.write(self.message + str(self.progBar) + ' '.join(after_args) + '\r')
sys.stdout.flush()
def __str__(self):
return str(self.progBar)
示例8: write_heuristics_data
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def write_heuristics_data(start, n, res_fname, states_fname='data/states.txt', search=a_star, h_name='linear_conflict', heuristic=NPuzzle.linear_conflict):
"""
Write a file with information on states, depths, expanded nodes, and
running time for the 3 heuristics implemented on a specific search method.
"""
from ProgressBar import ProgressBar
import time
import re
with open(res_fname, 'a') as res_f, open(states_fname, 'r') as s_f:
K = 3
goal = NPuzzle(K, range(K*K))
for i in range(start):
s_f.readline()
print 'Reading states from file {:s}'.format(states_fname)
print 'Writing {} states data to file {:s}'.format(n, res_fname)
pb = ProgressBar() # a simple pogressbar
pb.start()
f_format = '{};{};{};{}\n'
if start == 0:
columns = ['state', 'steps', h_name + '_nodes', h_name + '_time']
res_f.write(f_format.format(*columns))
for i in range(n - start):
state_str = s_f.readline().strip()
state = [int (b) for b in re.findall('[0-9]+', state_str)]
initial = NPuzzle(3, state)
percent = float(i+start)/(n)
pb.update(percent)
try:
init_time1 = time.time()
n1, s1, path1 = search(initial, goal, heuristic)
end_time1 = time.time()
t1 = end_time1 - init_time1
except KeyboardInterrupt:
break
except:
t1 = 'NaN'
n1 = 'NaN'
s1 = 'NaN'
res_f.write(f_format.format(initial, s1, n1, t1))
res_f.flush()
pb.finish()
示例9: PrintSiteReadinessMetricsStats
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def PrintSiteReadinessMetricsStats(self):
print "\nPrinting Site Readiness Metrics Statistics\n"
prog = ProgressBar(0, 100, 77)
fileHandle = open(self.fileReadinessStat , 'w')
sites = self.matrices.readiValues.keys()
sites.sort()
for sitename in sites:
dates = self.matrices.readiValues[sitename].keys()
dates.sort()
continue
for i in "T1","T2":
prog.increment(100./2.)
for dat in dates:
countR=0; countW=0; countNR=0; countSD=0; countna=0
for sitename in sites:
if sitename.find("T1_CH_CERN") == 0: continue
if not sitename.find(i+"_") == 0: continue
if self.SkipSiteOutput(sitename): continue
state = self.matrices.readiValues[sitename][dat]
if state == "R":
countR+=1
if state == "W":
countW+=1
if state == "NR":
countNR+=1
if state.find("n/a") == 0:
countna+=1
if state == "SD":
countSD+=1
if dat == self.tinfo.todaystamp: continue
tofile = "Site Readiness Metric " + i + " " + dat + " " + str(countR) + " " + str(countNR) + " " + str(countna) + " " + str(countW) + " " + str(countSD) + " " + str(countR+countNR+countW+countna+countSD) + "\n"
fileHandle.write(tofile)
fileHandle.close()
prog.finish()
示例10: EvaluateDailyMetric
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def EvaluateDailyMetric(self):
print "\nEvaluating Daily Status\n"
# set value for the 'Daily Metric' column in self.matrices.dailyMetrics
prog = ProgressBar(0, 100, 77)
for sitename in self.matrices.columnValues:
prog.increment(100./len(self.matrices.columnValues))
self.matrices.dailyMetrics[sitename] = {}
items = self.matrices.columnValues[sitename].keys()
items.sort()
status = ' '
for day in items:
status = 'O'
for crit in self.GetCriteriasList(sitename): # loop through the columns (criteria) that apply to this site
if not self.matrices.columnValues[sitename][day].has_key(crit):
info = {}
info['Status'] = 'n/a'
info['Color'] = 'white'
self.matrices.columnValues[sitename][day][crit] = info
if self.matrices.columnValues[sitename][day][crit]['Color'] == 'red':
status = 'E'
if self.matrices.columnValues[sitename][day]['Downtimes_top']['Color'] == 'brown':
status = 'SD'
# exclude sites that are not in SiteDB
testdate = date(int(day[0:4]),int(day[5:7]),int(day[8:10]))
sitedbtimeint = testdate - date(2009,11,03) # magic number - no idea where it comes from.
if sitedbtimeint.days >= 0:
if self.matrices.columnValues[sitename][day].has_key('IsSiteInSiteDB'):
if self.matrices.columnValues[sitename][day]['IsSiteInSiteDB']['Color'] == 'white':
status = 'n/a'
if day == self.tinfo.todaystamp:
status = ' '
self.matrices.dailyMetrics[sitename][day] = status
prog.finish()
示例11: EvaluateDailyMetric
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def EvaluateDailyMetric(self):
print "\nEvaluating Daily Metric\n"
# set value for the 'Daily Metric' column in self.matrices.dailyMetrics
# NOTE: also sets n/a in columnValues for missing metrics
prog = ProgressBar(0, 100, 77)
for sitename in self.matrices.columnValues:
prog.increment(100./len(self.matrices.columnValues))
self.matrices.dailyMetrics[sitename] = {}
items = self.matrices.columnValues[sitename].keys()
items.sort()
status = ' '
for day in items:
status = 'O' # initial value is OK ('O')
for crit in self.GetCriteriasList(sitename): # loop through the columns (criteria) that apply to this site and affect site status
if not self.matrices.columnValues[sitename][day].has_key(crit): # fill columnValues with 'n/a' for any missing values
self.matrices.columnValues[sitename][day][crit] = self.nullInfo()
if self.matrices.columnValues[sitename][day][crit]['Color'] == 'red': # if any individual metric is red, set status to error ('E')
status = 'E'
if self.matrices.columnValues[sitename][day]['Downtimes_top']['Color'] == 'brown': # if site was in downtime set to 'SD'
status = 'SD'
# exclude sites that are not in SiteDB
testdate = date(int(day[0:4]),int(day[5:7]),int(day[8:10]))
sitedbtimeint = testdate - date(2009,11,03) # magic number - no idea where it comes from.
if sitedbtimeint.days >= 0:
if self.matrices.columnValues[sitename][day].has_key('IsSiteInSiteDB'):
if self.matrices.columnValues[sitename][day]['IsSiteInSiteDB']['Color'] == 'white':
status = 'n/a'
#status = status
if day == self.tinfo.todaystamp: # set today's to the blank character
status = ' '
self.matrices.dailyMetrics[sitename][day] = status
prog.finish()
示例12: ProduceSiteReadinessHTMLViews
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
#.........这里部分代码省略.........
mes="\"Scheduled Downtimes\": site maintenances"
fileHandle.write("<td width=" + lw2 + " colspan=2><div id=\"legendexp\">" + mes + "</div></td>\n")
mes="\"Job Robot\":"
fileHandle.write("<td width=" + lw2 + " colspan=2><div id=\"legendexp\">" + mes + "</div></td>\n")
mes="\"Good Links\":"
fileHandle.write("<td width=" + lw2 + " colspan=2><div id=\"legendexp\">" + mes + "</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=green><div id=legflag>Up</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Site is not declaring Scheduled-downtime </div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=green><div id=legflag></div></td>\n")
if sitename.find('T1_') == 0:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is ≥ 90%</div></td>\n")
else:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is ≥ 80%</div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=green><div id=legflag></div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = at least half of links have 'good' transfers (i.e. with transfer quality > 50%)</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=brown><div id=legflag>SD</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = full-site in SD OR all CMS SE(s) in SD OR all CMS CE(s) in SD</div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=red><div id=legflag></div></td>\n")
if sitename.find('T1_') == 0:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is < 90%</div></td>\n")
else:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is < 80%</div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=red><div id=legflag></div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Otherwise</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=yellow><div id=legflag>~</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Some SE or CE services (not all) Downtime</div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=orange><div id=legflag>-</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Jobs submitted but not finished</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=silver><div id=legflag>UD</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = full-site in UD OR all CMS SE(s) in UD OR all CMS CE(s) in UD</div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=white><div id=legflag>n/a</div></td>\n")
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is n/a</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=10>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
mes="\"SAM Availability\":"
fileHandle.write("<td width=" + lw2 + " colspan=2><div id=\"legendexp\">" + mes + "</div></td>\n")
if sitename.find('T1_') == 0:
mes="\"Active T1 links from T0\":"
else:
mes="\"Active T2 links to T1s\":"
fileHandle.write("<td width=" + lw2 + " colspan=2><div id=\"legendexp\">" + mes + "</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=15>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=green><div id=legflag></div></td>\n")
if sitename.find('T1_') == 0:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = SAM availability is ≥ 90% </div></td>\n")
else:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = SAM availability is ≥ 80% </div></td>\n")
fileHandle.write("<td width=" + lw1 + " bgcolor=green><div id=legflag></div></td>\n")
if sitename.find('T1_') == 0:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Link from T0_CH_CERN is DDT-commissioned </div></td>\n")
else:
fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Site has ≥ 2 DDT-commissioned links to T1 sites </div></td>\n")
示例13: ProduceSiteReadinessRankingPlots
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def ProduceSiteReadinessRankingPlots(self):
print "\nProducing Site Readiness Ranking plots\n"
prog = ProgressBar(0, 100, 77)
sitesit = self.matrices.readiValues.keys()
sitesit.sort()
for dayspan in 30, 15, 7:
prog.increment(100./3.)
for pl in 'SD_perc', 'R+Wcorr_perc':
for i in "T1","T2":
dataR = {}
filename = self.plotOutDir + "/" + i + "_" + pl + "_last" + str(dayspan) + "days_" + self.tinfo.timestamphtml + ".png"
for sitename in sitesit:
if not sitename.find(i+"_") == 0 : continue
if self.SkipSiteOutput(sitename): continue
if pl == 'SD_perc' and self.matrices.stats[sitename][dayspan][pl]==0.: continue # Do not show Up sites on SD plots.
if sitename == 'T1_CH_CERN': sitename = 'T2_CH_CERN'
dataR[sitename+" ("+str(self.matrices.stats[sitename][dayspan]["SD_perc"])+"%)"] = self.matrices.stats[sitename][dayspan][pl]
if len(dataR) == 0:
os.system("touch %s" % filename)
continue
norms = normalize(0,100)
mapper = cm.ScalarMappable( cmap=cm.RdYlGn, norm=norms )
# Hack to make mapper work:
def get_alpha(*args, **kw):
return 1.0
mapper.get_alpha = get_alpha
A = linspace(0,100,100)
mapper.set_array(A)
pos = arange(len(dataR))+.5 # the bar centers on the y axis
dataS = dataR.items()
dataS.sort(lambda x,y: cmp(x[1],y[1]))
ytext = []
val = []
color = []
total=0
ent=0
ent2=0
for t in range(0,len(dataS)):
ytext.append(dataS[t][0])
val.append(dataS[t][1])
color.append( mapper.to_rgba( dataS[t][1] ) )
total += 1
if i == 'T1' and dataS[t][1] <= 90 : ent+=1
if i == 'T1' and dataS[t][1] > 90 : ent2+=1
if i == 'T2' and dataS[t][1] <= 80 : ent+=1
if i == 'T2' and dataS[t][1] > 80 : ent2+=1
if pl == 'R+Wcorr_perc':
metadataR = {'title':'%s Readiness Rank last %i days (+SD %%) [%s]' % (i,int(dayspan),self.tinfo.todaystamp), 'fixed-height':False }
if pl == 'SD_perc':
metadataR = {'title':'Rank for %s Scheduled Downtimes last %i days [%s]' % (i,int(dayspan),self.tinfo.todaystamp), 'fixed-height':True}
fig = Figure()
canvas = FigureCanvas(fig)
if i == 'T1':
SRlim=90
fig.set_size_inches(7,4)
else:
SRlim=80
fig.set_size_inches(7.5,9.5)
ax = fig.add_subplot(111)
fig.subplots_adjust(left=0.2, right=0.97)
ax.set_autoscale_on(False)
ax.barh(pos,val, align='center',color=color)
ax.set_xlim([0,100])
ax.set_ylim([0,len(dataS)])
ax.set_yticklabels(ytext,fontsize=8,family='sans-serif')
ax.set_yticks(pos)
ax.set_title(metadataR['title'],fontsize=14)
ax.set_xlabel('Site Readiness %',fontsize=12,family='sans-serif')
if pl == 'R+Wcorr_perc':
ax.axvline(x=SRlim, ymin=0, ymax=1,color='red',ls=':',lw=3)
if i == 'T1' :
ax.text(91,0.65,str(ent2)+"/"+str(total)+" >90%",color='darkgreen',fontsize=6)
ax.text(91,0.3,str(ent)+"/"+str(total)+" $\leq$90%",color='red',fontsize=6)
if i == 'T2' :
ax.text(81,2,str(ent2)+"/"+str(total)+" >80%",color='darkgreen',fontsize=6)
ax.text(81,1,str(ent)+"/"+str(total)+" $\leq$80%",color='red',fontsize=6)
canvas.print_figure(filename)
prog.finish()
示例14: ProduceSiteReadinessHTMLViews
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
#.........这里部分代码省略.........
if met1 == 't' and not met in met2 : continue # ignore
if sitename.find("T1_CH_CERN") == 0 and met == 'T1linksfromT0': continue # ignore
if met == 'SAMAvailability':
fileHandle.write("<tr><td width=\"" + metricw + "\"><div id=\"metrics-header\"><font color=\"orange\">" + self.cinfo.metlegends[met] + ": </font></div></td>\n")
elif met == 'LifeStatus':
fileHandle.write("<tr><td width=\"" + metricw + "\"><div id=\"metrics-header\">" + self.cinfo.metlegends[met] + ": </div></td><td width=\"" + dayw + "\" bgcolor=white>"+"</td>\n")
else:
fileHandle.write("<tr><td width=\"" + metricw + "\"><div id=\"metrics-header\">" + self.cinfo.metlegends[met] + ": </div></td>\n")
igdays=0
for datesgm in dates: # write out a line for each constituent metric
igdays+=1
if (self.cinfo.days - igdays)>self.cinfo.daysToShow-1: continue
state = self.matrices.columnValues[sitename][datesgm][met]['Status']
colorst=self.matrices.columnValues[sitename][datesgm][met]['Color']
datesgm1 = datesgm[8:10]
c = datetime.datetime(*time.strptime(datesgm,"%Y-%m-%d")[0:5])
if not sitename in self.weekendSites and (c.weekday() == 5 or c.weekday() == 6) and sitename.find('T2_') == 0 and met != "LifeStatus": # id. weekends
if state != " " :
if self.matrices.columnValues[sitename][datesgm][met].has_key('URL') and self.matrices.columnValues[sitename][datesgm][met]['URL'] != ' ' :
stateurl=self.matrices.columnValues[sitename][datesgm][met]['URL']
fileHandle.write("<td width=\"" + dayw + "\" bgcolor=grey><a href=\""+stateurl+"\">"+"<div id="+dividMetrics+">" + state + "</div></a></td>\n")
else:
fileHandle.write("<td width=\"" + dayw + "\" bgcolor=grey><div id="+dividMetrics+">" + state + "</div></td>\n")
else:
fileHandle.write("<td width=\"" + dayw + "\" bgcolor=white><div id="+dividMetrics+">" + state + "</div></td>\n")
else:
if self.matrices.columnValues[sitename][datesgm][met].has_key('URL') and self.matrices.columnValues[sitename][datesgm][met]['URL'] != ' ' :
stateurl=self.matrices.columnValues[sitename][datesgm][met]['URL']
fileHandle.write("<td width=\"" + dayw + "\" bgcolor=" + colorst + "><a href=\""+stateurl+"\">"+"<div id="+dividMetrics+">" + state + "</div></a></td>\n")
else:
fileHandle.write("<td width=\"" + dayw + "\" bgcolor=" + colorst + "><div id="+dividMetrics+">" + state + "</div></td>\n")
fileHandle.write("</tr>\n")
if met == 'SiteReadiness':
fileHandle.write("<tr height=4><td width=" + tablew + " colspan=" + colspans22 + " bgcolor=black></td></tr>\n")
fileHandle.write("<tr height=2><td width=" + tablew + " colspan=" + colspans22 + " bgcolor=white></td></tr>\n")
fileHandle.write("<tr height=4><td width=" + tablew + " colspan=" + colspans22 + " bgcolor=black></td></tr>\n")
fileHandle.write("<tr height=4><td width=" + metricw + "></td>\n")
igdays=0
for datesgm in dates:
igdays+=1
if (self.cinfo.days - igdays)>self.cinfo.daysToShow-1: continue
datesgm1 = datesgm[8:10]
c = datetime.datetime(*time.strptime(datesgm,"%Y-%m-%d")[0:5])
if c.weekday() == 5 or c.weekday() == 6: # id. weekends
fileHandle.write("<td width=" + dayw + " bgcolor=grey> <div id=\"date\">" + datesgm1 + "</div></td>\n")
else:
fileHandle.write("<td width=" + dayw + " bgcolor=lightgrey> <div id=\"date\">" + datesgm1 + "</div></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr height=4><td width=" + metricw + "></td>\n")
fileHandle.write("<td width=" + daysw + " colspan=" + colspans1 + " bgcolor=black></td></tr>\n")
fileHandle.write("<tr><td width=" + metricw + "></td>\n")
lastmonth=""
igdays=0
for datesgm in dates:
igdays+=1
if (self.cinfo.days - igdays)>self.cinfo.daysToShow-1: continue
c = datetime.datetime(*time.strptime(datesgm,"%Y-%m-%d")[0:5])
month = c.strftime("%b")
if month != lastmonth:
fileHandle.write("<td width=" + dayw + " bgcolor=black> <div id=\"month\">" + month + "</div></td>\n")
lastmonth=month
else:
fileHandle.write("<td width=" + dayw + "></td>\n")
fileHandle.write("</tr>\n")
fileHandle.write("<tr><td width=" + metricw + "></td>\n")
fileHandle.write("<td width=" + scdaysw1 + " colspan=" + colspans3 + "></td>\n")
fileHandle.write("</table>\n")
# report time
fileHandle.write("<div id=\"leg1\">" + self.reptime + "</div>\n")
fileHandle.write("</div>\n")
# print instructions
if sitename.find('T1_') == 0:
fileHandle.write(self.t1Inst)
elif sitename.find('T2_') == 0:
fileHandle.write(self.t2Inst)
fileHandle.write("<p>\n")
fileHandle.write("<p><br>\n")
fileHandle.write("</center></html></body>")
fileHandle.close()
prog.finish()
示例15: EvaluateSiteReadiness
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
def EvaluateSiteReadiness(self):
print "\nEvaluating Site Readiness\n"
prog = ProgressBar(0, 100, 77)
sitesit = self.matrices.dailyMetrics.keys()
sitesit.sort()
for sitename in sitesit:
prog.increment(100./len(sitesit))
if not self.matrices.readiValues.has_key(sitename):
self.matrices.readiValues[sitename] = {}
tier = sitename.split("_")[0]
start = self.tinfo.today
stop = self.tinfo.today - datetime.timedelta(self.cinfo.days - self.cinfo.daysSC)
for iday in daterange(start, stop, datetime.timedelta(-1)): # loop from today to the first day on which we try to calculate the readiness (default: today to (today - 60 - 7) days)
idaystamp = iday.strftime("%Y-%m-%d")
statusE = 0 # number of days over the previous daysSC days that dailyMetric was in error
for jday in daterange(iday, iday - datetime.timedelta(self.cinfo.daysSC), datetime.timedelta(-1)): # loop over the dailyMetric values from the previous daysSC days
jdaystamp = jday.strftime("%Y-%m-%d")
if self.matrices.dailyMetrics[sitename][jdaystamp] == 'E': # if dailyMetric in error
if ( tier == "T2" or tier == "T3") and (jday.weekday() == 5 or jday.weekday() == 6):
if not self.options.t2weekends: # skip Errors on weekends for T2s
continue
statusE += 1
status = "n/a"
color = "white"
previousDayStamp = (iday - datetime.timedelta(1)).strftime("%Y-%m-%d") # iday minus one day
dailyMetric = self.matrices.dailyMetrics[sitename][idaystamp]
if statusE > 2: # if in error for more than two of the last daysSC days
status="NR"
color="red"
if dailyMetric == 'E' and statusE <= 2 : # if in error today
status="W"
color="yellow"
if dailyMetric == 'O' and statusE <= 2 : # if ok
status="R"
color="green"
if dailyMetric == 'O' and self.matrices.dailyMetrics[sitename][previousDayStamp] == 'O':
status="R"
color="green"
if dailyMetric == 'SD':
status='SD'
color="brown"
self.matrices.readiValues[sitename][idaystamp] = status # set actual SR value
# correct weekend t2 and t3 readiness values to 'R' if they're in downtime, otherwise to friday's value
if tier=="T2" or tier=="T3":
start = self.tinfo.today - datetime.timedelta(self.cinfo.days - self.cinfo.daysSC - 3)
stop = self.tinfo.today
for iday in daterange(start, stop):
idaystamp = iday.strftime("%Y-%m-%d")
previousDayStamp = (iday - datetime.timedelta(1)).strftime("%Y-%m-%d")
if self.matrices.dailyMetrics[sitename][idaystamp] == 'E':
if iday.weekday() == 5 or iday.weekday() == 6: # id. weekends
if not self.options.t2weekends: # skip Errors on weekends for T2s
if self.matrices.readiValues[sitename][previousDayStamp] == 'SD':
self.matrices.readiValues[sitename][idaystamp] = 'R'
else:
self.matrices.readiValues[sitename][idaystamp] = self.matrices.readiValues[sitename][previousDayStamp]
prog.finish()
# put in blank current day
for sitename in self.matrices.dailyMetrics:
for col in self.cinfo.urls:
if self.matrices.columnValues[sitename][self.tinfo.todaystamp].has_key(col):
self.matrices.columnValues[sitename][self.tinfo.todaystamp][col]['Status'] = ' '
self.matrices.columnValues[sitename][self.tinfo.todaystamp][col]['Color'] = 'white'
self.matrices.readiValues[sitename][self.tinfo.todaystamp] = ' '