当前位置: 首页>>代码示例>>Python>>正文


Python ProgressBar.finish方法代码示例

本文整理汇总了Python中ProgressBar.ProgressBar.finish方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.finish方法的具体用法?Python ProgressBar.finish怎么用?Python ProgressBar.finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressBar.ProgressBar的用法示例。



在下文中一共展示了ProgressBar.finish方法的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:28,代码来源:OutputWriter.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:27,代码来源:OutputWriter.py


示例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()
开发者ID:gastonlp,项目名称:SiteReadiness,代码行数:37,代码来源:OutputWriter.py


示例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()
开发者ID:gastonlp,项目名称:SiteReadiness,代码行数:61,代码来源:OutputWriter.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:60,代码来源:ReadinessMaker.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:58,代码来源:OutputWriter.py


示例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)
开发者ID:davidascher,项目名称:batchr,代码行数:57,代码来源:batchr.py


示例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()
开发者ID:jpaulofb,项目名称:NPuzzleSolver,代码行数:52,代码来源:misc.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:40,代码来源:OutputWriter.py


示例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()
开发者ID:amaltaro,项目名称:SiteSupportFiles,代码行数:40,代码来源:ReadinessMaker.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:38,代码来源:ReadinessMaker.py


示例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 &ge; 90%</div></td>\n")
             else:
                 fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = Job success rate is &ge; 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 &ge; 90% </div></td>\n")
             else:   
                 fileHandle.write("<td width=" + lw2 + "><div id=\"legend\"> = SAM availability is &ge; 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 &ge; 2 DDT-commissioned links to T1 sites </div></td>\n")            
开发者ID:altundag,项目名称:SiteSupportFiles,代码行数:70,代码来源:OutputWriter.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:88,代码来源:OutputWriter.py


示例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()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:104,代码来源:OutputWriter.py


示例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] = ' '
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:70,代码来源:ReadinessMaker.py


示例16: ProduceSiteReadinessHTMLViews

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]

#.........这里部分代码省略.........
                        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="metrics2">'
                                    + state
                                    + "</div></a></td>\n"
                                )
                            else:
                                fileHandle.write(
                                    '<td width="'
                                    + dayw
                                    + '" bgcolor='
                                    + colorst
                                    + '><div id="metrics2">'
                                    + state
                                    + "</div></td>\n"
                                )
                    fileHandle.write("</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()
开发者ID:gastonlp,项目名称:SiteReadiness,代码行数:104,代码来源:OutputWriter.py


示例17: GetDowntimes

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]
    def GetDowntimes(self):
        print "\nExtracting Scheduled Downtime Topology Daily Metrics for CMS sites\n"
        # Leer Downtimes Topology (por ahora uso Time y EndTime para decidir cuanto duran los Downtimes)
        # por defecto todos los dias son Ok, y uso Time y EndTime para asignar los Downtimes.
        prog = ProgressBar(0, 100, 77)
        downtimedays = self.cinfo.days
        #downtimedays = 120
        for sitename in self.matrices.xmlInfo:
            prog.increment(100./len(self.matrices.xmlInfo))
            if not self.matrices.columnValues.has_key(sitename): # add dict for site
                print "not self.matrices.columnValues.has_key " + sitename
                self.matrices.columnValues[sitename]={}
            for col in self.cinfo.urls: # loop over columns
                if col != "Downtimes_top":
                    continue
                infocol = {}
                #if sitename == "T2_US_UCSD": 
                #  print self.matrices.xmlInfo['T2_US_UCSD'][col]
                if not self.matrices.xmlInfo[sitename].has_key(col):
                    #print "self.matrices.xmlInfo[sitename].has_key(col) " + sitename + ":" + col  
                    self.matrices.xmlInfo[sitename][col] = {}
                # set downtime metric to green by default
                for i in range(0,downtimedays+1):
                    delta = datetime.timedelta(downtimedays-i);
                    dayloop = self.tinfo.today - delta
                    dayloopstamp = dayloop.strftime("%Y-%m-%d")

                    if not self.matrices.columnValues[sitename].has_key(dayloopstamp):
                        self.matrices.columnValues[sitename][dayloopstamp] = {}
                    infocol['Status'] = "Up"
                    infocol['Color'] = "green"
                    infocol['URL'] = ' ' 
                    self.matrices.columnValues[sitename][dayloopstamp][col] = infocol
    
                items = self.matrices.xmlInfo[sitename][col].keys()
                items.sort()
                for stdate in items:
                    colorTmp = self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][stdate]['COLOR']] # color taken from self.matrices.xmlInfo
                    if colorTmp == "white" or  colorTmp == "green": # if they're ok, they don't need to be corrected for downtimes
                        continue
                    sttdate = stdate[0:stdate.find(" ")]
                    enddate = self.matrices.xmlInfo[sitename][col][stdate]['EndTime'][0:self.matrices.xmlInfo[sitename][col][stdate]['EndTime'].find(" ")]
                    cl = self.matrices.xmlInfo[sitename][col][stdate]['COLOR']
    
                    for i in range(0,downtimedays+1):
                        delta = datetime.timedelta(downtimedays-i);
                        dayloop = self.tinfo.today - delta
                        dayloopstamp = dayloop.strftime("%Y-%m-%d")
                        kk=0
                        if stdate.find(dayloopstamp) == 0:
                            wloop=True
                            while (wloop):
                                cdate = datetime.datetime(*time.strptime(sttdate,"%Y-%m-%d")[0:5])
                                delta = datetime.timedelta(kk);
                                dayloop = cdate + delta
                                dayloopstamp  = dayloop.strftime("%Y-%m-%d")
    
                                # I'm guessing that this is supposed skip brown entries, but the first and last if statements seem to have typos.
                                if self.matrices.columnValues[sitename].has_key(col):
                                    if self.matrices.columnValues[sitename][col].has_key(dayloopstamp):
                                        if self.matrices.columnValues[sitename][col][dayloopstamp].has_key('Color'):
                                            if self.matrices.columnValues[sitename][col][dayloopstamp].has_key('Color') == 'brown':
                                                kk+=1
                                                continue
    
                                # get downtime info from sites and put it into self.matrices.columnValues
                                values = {}
                                if colorTmp == 'brown':
                                    values['Color'] = 'brown'
                                    values['Status'] = 'SD'
                                    values['URL'] = self.matrices.xmlInfo[sitename][col][stdate]['URL']
                                if colorTmp == 'grey':
                                    if self.matrices.xmlInfo[sitename][col][stdate]['Status'].find("OUTAGE UNSCHEDULED") == 0:
                                        values['Color'] = 'silver'
                                        values['Status'] = 'UD'
                                        values['URL'] = self.matrices.xmlInfo[sitename][col][stdate]['URL']
                                    else:
                                        values['Color'] = 'yellow'
                                        values['Status'] = '~'
                                        values['URL'] = self.matrices.xmlInfo[sitename][col][stdate]['URL']
                                if colorTmp == 'yellow':
                                    values['Color'] = 'yellow'
                                    values['Status'] = '~'
                                    values['URL'] = self.matrices.xmlInfo[sitename][col][stdate]['URL']
                                
                                if dayloop > self.tinfo.today: break # ignore future downtimes
                                self.matrices.columnValues[sitename][dayloopstamp][col] = values
                                kk+=1
    
                                if (dayloopstamp == enddate): wloop=False
    
                # set today's downtime status to white
                nullVals = {}
                nullVals['Status'] = ' '
                nullVals['URL'] = ' '
                nullVals['Color'] = 'white'
                self.matrices.columnValues[sitename][self.tinfo.todaystamp][col] = nullVals
    
        prog.finish()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:101,代码来源:ReadinessMaker.py


示例18: FillSummaryMatrix

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import finish [as 别名]

#.........这里部分代码省略.........
             for coldate in items: # loop over each time/date combination
                 xmltime = datetime.datetime(*time.strptime(self.matrices.xmlInfo[sitename][col][coldate]['Time'], "%Y-%m-%d %H:%M:%S")[0:6])
                 xmlendtime = datetime.datetime(*time.strptime(self.matrices.xmlInfo[sitename][col][coldate]['EndTime'], "%Y-%m-%d %H:%M:%S")[0:6])
 
                 startxmldatetmp = xmltime.strftime("%Y-%m-%d 00:00:00")
                 startxmldate = datetime.datetime(*time.strptime(startxmldatetmp, "%Y-%m-%d %H:%M:%S")[0:6])
 
                 EndTXML = True
                 i = 0
                 while ( EndTXML ):
                     d = datetime.timedelta(i) # convert i to number of days
                     i += 1
                     dayloop = startxmldate + d
                     dayloopstamp = dayloop.strftime("%Y-%m-%d")
                     dayloopstamp2 = dayloop.strftime("%Y-%m-%d 00:00:00")
                     looptime = datetime.datetime(*time.strptime(dayloopstamp2, "%Y-%m-%d %H:%M:%S")[0:6])
                     if dayloop > self.tinfo.today:
                         EndTXML = False
                         continue
                     diff1  = xmltime-looptime
                     diff1s = (diff1.days*86400+diff1.seconds)
                     diff2  = xmlendtime-looptime
                     diff2s = (diff2.days*86400+diff2.seconds)
                     diff3  = xmlendtime-xmltime
                     diff3s = (diff3.days*86400+diff3.seconds)
                     if diff1s<=0 and diff2s>0:
                         if diff2s>=86400: validity=86400
                         else: validity=diff2s
                     if diff1s>0 and diff1s<86400:
                         if diff2s>86400: validity=86400-diff1s
                         else: validity=diff3s
                     if diff1s<0 and diff2s<=0:
                         EndTXML=False
                         continue
                       
                     if self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][coldate]['COLOR']] == "green":
                         status=self.matrices.xmlInfo[sitename][col][coldate]['Status']
                         statusu=self.matrices.xmlInfo[sitename][col][coldate]['URL']
                         statusc='green'
                         if self.matrices.xmlInfo[sitename][col][coldate]['Status']=="pend":
                             status='-'
                             statusc='orange'
                     elif self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][coldate]['COLOR']] == "red":
                         status=self.matrices.xmlInfo[sitename][col][coldate]['Status']
                         statusu=self.matrices.xmlInfo[sitename][col][coldate]['URL']
                         statusc='red'
                     elif self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][coldate]['COLOR']] == "yellow":
                         status=self.matrices.xmlInfo[sitename][col][coldate]['Status']
                         statusu=self.matrices.xmlInfo[sitename][col][coldate]['URL']
                         statusc='yellow'
                     elif self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][coldate]['COLOR']] == "white":
                         status='n/a'
                         statusu=' '
                         statusc='white'
                     else:
                         status=self.matrices.xmlInfo[sitename][col][coldate]['Status']
                         statusu=self.matrices.xmlInfo[sitename][col][coldate]['URL']
                         statusc=self.cinfo.colorCodes[col][self.matrices.xmlInfo[sitename][col][coldate]['COLOR']]
 
                     dayloopstamp3 = self.ShiftDayForMetric(dayloop,col)
                     todayst = date(int(self.tinfo.todaystamp[0:4]),int(self.tinfo.todaystamp[5:7]),int(self.tinfo.todaystamp[8:10]))
                     dayloop3 = date(int(dayloopstamp3[0:4]),int(dayloopstamp3[5:7]),int(dayloopstamp3[8:10]))
 
                     if abs((dayloop3-todayst).days) > self.cinfo.days:
                         continue
                     if status == "Ready":
                        status = "R"
                     elif status == "NotReady":
                        status = "NR"
                     elif status == "Downtime":
                        status = "SD"
                     elif status == "Waiting_Room":
                        status = "WR"
                     elif status == "Morgue":
                        status = "M" 
                     elif status == "OK" or status == "Ok":
                        status = "O"
                     elif status == "Error":
                        status = "E"
                     # set the actual values in self.matrices.columnValues
                     infocol = {}
                     infocol['Status'] = status
                     infocol['Color'] = statusc
                     infocol['URL'] = statusu
                     infocol['validity'] = validity
                     if self.matrices.columnValues[sitename][dayloopstamp3][col].has_key('validity'):
                         if validity > self.matrices.columnValues[sitename][dayloopstamp3][col]['validity']:
                             self.matrices.columnValues[sitename][dayloopstamp3][col] = infocol
                     else:
                         self.matrices.columnValues[sitename][dayloopstamp3][col] = infocol
                                 
                     if dayloopstamp == self.tinfo.todaystamp:
                         infocol = {}
                         infocol['Status'] = ' '
                         infocol['Color'] = 'white'
                         infocol['URL'] = ' '
                         infocol['validity'] = '0'                       
                         self.matrices.columnValues[sitename][dayloopstamp][col] = infocol
 
     prog.finish()
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:104,代码来源:ReadinessMaker.py


示例19: 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]
         for i in range(0, self.cinfo.days-self.cinfo.daysSC):
             dayloop = self.tinfo.today - datetime.timedelta(i)
             dayloopstamp = dayloop.strftime("%Y-%m-%d")
             dayloopstampm1 = (dayloop-datetime.timedelta(1)).strftime("%Y-%m-%d")
             dayloopstampm2 = (dayloop-datetime.timedelta(2)).strftime("%Y-%m-%d")
             statusE = 0
             for j in range(0,self.cinfo.daysSC):
                 dayloop2 = dayloop - datetime.timedelta(j);
                 dayloopstamp2 = dayloop2.strftime("%Y-%m-%d")
                 dayofweek2 = dayloop2.weekday()
                 if self.matrices.dailyMetrics[sitename][dayloopstamp2] == 'E': # Daily Metric value
                     if ( tier == "T2" or tier == "T3") and (dayofweek2 == 5 or dayofweek2 == 6):
                         if not self.options.t2weekends: # skip Errors on weekends for T2s
                             continue
                     statusE += 1
 
             status = "n/a"
             colorst = "white"
             if statusE > 2:
                 status="NR"
                 colorst="red"
             if self.matrices.dailyMetrics[sitename][dayloopstamp] == 'E' and statusE <= 2 :
                 status="W"
                 colorst="yellow"
             if self.matrices.dailyMetrics[sitename][dayloopstamp] == 'O' and statusE <= 2 :
                 status="R"
                 colorst="green"
             if self.matrices.dailyMetrics[sitename][dayloopstamp] == 'O' and self.matrices.dailyMetrics[sitename][dayloopstampm1] == 'O':
                 status="R"
                 colorst="green"
             if self.matrices.dailyMetrics[sitename][dayloopstamp] == 'SD':
                 status='SD'
                 colorst="brown"
             self.matrices.readiValues[sitename][dayloopstamp] = status # set actual SR value
 
         if tier=="T2" or tier=="T3":
             for i in range(0, self.cinfo.days-self.cinfo.daysSC):
                 dsc = datetime.timedelta(self.cinfo.days - self.cinfo.daysSC - 1);
                 dayloop = self.tinfo.today - dsc + datetime.timedelta(i)
                 dayofweek = dayloop.weekday()
                 dayloopstamp = dayloop.strftime("%Y-%m-%d")
                 dayloopstampm1 = (dayloop - datetime.timedelta(1)).strftime("%Y-%m-%d")
                 if self.matrices.dailyMetrics[sitename][dayloopstamp] == 'E':
                     if dayofweek == 5 or dayofweek == 6: # id. weekends
                         if not self.options.t2weekends: # skip Errors on weekends for T2s
                             if i == 0 or i == 1:
                                 self.matrices.readiValues[sitename][dayloopstamp] == 'R'
                                 continue
                             if self.matrices.readiValues[sitename][dayloopstampm1] == 'SD':
                                 self.matrices.readiValues[sitename][dayloopstamp] = 'R'
                             else:
                                 self.matrices.readiValues[sitename][dayloopstamp] = self.matrices.readiValues[sitename][dayloopstampm1]
                         
     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] = ' '
开发者ID:amaltaro,项目名称:SiteSupportFiles,代码行数:74,代码来源:ReadinessMaker.py



注:本文中的ProgressBar.ProgressBar.finish方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。