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


Python ProgressBar.increment方法代码示例

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


在下文中一共展示了ProgressBar.increment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PrintDailyMetrics

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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: ProduceSiteReadinessSSBFile

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例3: ProduceSiteReadinessSSBFiles

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例4: PrintDailyMetricsStats

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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 increment [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 increment [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: PrintSiteReadinessMetricsStats

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例8: EvaluateDailyMetric

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例9: EvaluateDailyMetric

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例10: ProduceSiteReadinessRankingPlots

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例11: ProduceSiteReadinessHTMLViews

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [as 别名]
    def ProduceSiteReadinessHTMLViews(self):
        print "\nProducing Site Readiness HTML view\n"
        colspans1 = str(self.cinfo.daysToShow+1)
        colspans2 = str(self.cinfo.daysToShow+1)
        colspans22 = str(self.cinfo.daysToShow+2)
        colspans3 = str(self.cinfo.daysSC)
        colspans4 = str(self.cinfo.daysSC)
        colspans5 = str(self.cinfo.daysToShow-self.cinfo.daysSC)

        dw = 45
        mw = 325

        tablew = str((self.cinfo.daysToShow)*dw+mw)
        dayw = str(dw)
        metricw = str(mw)
        daysw = str((self.cinfo.daysToShow)*dw)
        scdaysw1 = str((self.cinfo.daysSC)*dw)
        scdaysw = str((self.cinfo.daysSC)*dw)

        filehtml = self.htmlOutDir + '/SiteReadinessReport_' + self.tinfo.timestamphtml +'.html'
        fileHandle = open ( filehtml , 'w' )

        fileHandle.write("<html><head><title>CMS Site Readiness</title><link type=\"text/css\" rel=\"stylesheet\" href=\""+self.options.css+"/style-css-reports.css\"/></head>\n")
        fileHandle.write("<body><center>\n")
        fileHandle.write('<h1 style="line-height:200%">Site Readiness Report</h1>')

        sitesit = self.matrices.readiValues.keys()
        sitesit.sort()

        prog = ProgressBar(0, 100, 77)
        for sitename in sitesit:
            prog.increment(100./len(sitesit))
            if not self.SkipSiteOutput(sitename):
                fileHandle.write("<a name=\""+ sitename + "\"></a>\n\n")
                fileHandle.write("<div id=para-"+ sitename +">\n")

                fileHandle.write("<table border=\"0\" cellspacing=\"0\" class=stat>\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>\n")
                fileHandle.write("<td width=\"" + metricw + "\"></td>\n")
                fileHandle.write("<td width=\"" + daysw + "\" colspan=" + colspans1 + " bgcolor=darkblue><div id=\"site\">" + sitename + "</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 height=7><td width=" + metricw + "></td>\n")
                fileHandle.write("<td width=" + daysw + " colspan=" + colspans1 + "></td></tr>\n")

                dates = self.matrices.dailyMetrics[sitename].keys()
                dates.sort()

                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")
                igdays=0
                indmetrics = self.cinfo.metorder.keys()
                indmetrics.sort()

                for metnumber in indmetrics:

                    met = self.cinfo.metorder[metnumber] #colName
                    met1 = self.cinfo.printCol[met] #pCol (print permission)
                    tier = sitename.split("_")[0]
                    met2 = self.cinfo.criteria[tier]
                    dividMetrics = '"metrics2"'
                    if met == 'LifeStatus' or met == 'SiteReadiness':
                       dividMetrics = '"daily-metric"'
                    #if not self.matrices.columnValues[sitename][dates[0]].has_key(met) or met == 'IsSiteInSiteDB': continue # ignore
                    if not self.matrices.columnValues[sitename][dates[0]].has_key(met) or met1 == '0' : continue # ignore
                    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:
#.........这里部分代码省略.........
开发者ID:CMSCompOps,项目名称:SiteReadiness,代码行数:103,代码来源:OutputWriter.py

示例12: GameFrame

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [as 别名]
class GameFrame(Frame):
    
    def __init__(self, parent):
        Frame.__init__(self, parent, width=600, height=250)
        self.parent = parent    
       
    def init_gui(self):

        correct = """R0lGODlhQABAAOeqAAAAAAABAAACAAADAAAEAAAFAAAFAQAGAQAHAQEHAQEIAQEJAQEKAQEKAgEL
AgEMAgENAgEPAgIPAgIQAgIRAwITAwIUAwIVBAMVBAIWAwIWBAIXBAMXBAMYAwIZBAMZBAMaBQMb
BAMdBQMeBQMfBQMgBQQgBQQiBgQkBgQlBgQmBwQnBwUnBgUoBwUqBwUrBwUsBwUsCAUtCAUuCAUv
CAYvCAUxCAYyCQYzCAY0CQY1CgY2CQY3CQc3CgY5Cgc5Cgc7Cgc+Cwg/CwdACwhACwhBCwhCCwhG
DAhHDAhIDQlLDQlMDglNDglPDglQDglRDglSDgpUDwpWDwtWDwpXDwpZDwtaEAtfEQtgEQthEQxk
EQxkEgxlEgxnEgxoEw1oEgxpEgxqEw1qEg1rEwxsEw1sEg1tEw1vEw1wFA1yFA5yFA1zFA50FA50
FQ51FA52FQ95Fg56FQ57Fg97FQ99Fg9+Fg9/Fg+AFhCAFg+BFhCCFhCEFxCGFxCHGBCIGBCKGBGK
GBCLGBGMGRGNGRGOGRGQGRGRGRGRGhGSGRGTGhKTGRKTGhGUGhKVGhKXGhKXGxKYGhKaGxKbGxKc
GxKdGxKdHBOdGxOdHBKeHBOeGxOeHBOfHBOgHBOhHBOiHBOiHROjHBOjHROkHRSkHROlHRSlHRSm
HRSnHRSoHRSrHv//////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////yH+EUNyZWF0ZWQgd2l0aCBH
SU1QACH5BAEKAP8ALAAAAABAAEAAAAj+AP8JHEiwoMGDCBMqPAhgocOHEB0CaBixosWFEyde3MhR
YEaKHUNC/CiyJMYHCTSaXGkQgAcVKVnKHAhgBZIIIGeanAiki4acOkVOlJInBNCgHQEIELOIxFGk
GwFASLNJxVOoFgFUiFOKx1WsEQFY0GOqiQCwIQF0ECSqi4KvaDGKWNRJjgW4cRMCOEGI06AWePMy
ROGnU6QggQUXBIBij6dPUBIrptk4lKkuAiRPBpCCT6hQdipoVgxgBB9PnAzBGC0YQAY7mzRJWsI6
L4AIazTpVkNg8kgFXDhpwqTorm+JA6aE0kRpk47acQEkMUVJU6cs0NEC8FGKEiVOfQb+ZMcKgMWk
TM0joRgPFQCIQMw1bXpy9rjC22+Ea+IUZwJ7pAZcIVx1jdjwX1AAKFHJJt5lgsWBOgGwAyScUHKJ
JoJIAKFMpRlSIXOj3LAhSwAkgMeHlIDixYgkauGdJpds4ggFLO5EhCOaWMKcKUMEEGFaJfzBoG6d
vAEBgipl9cAZoFRXXSQ41OgRAAHUJgATp1Sn2yZjJNBeARi8FZYMoGByoW6IrEbeD04Y9RAAFBwy
JHOYdCFlS1T8UQROCwVgxocwapIIB3cuBsAWppgxQ5KLGfGibpSI4kShLTnQRiqEWPHBUQCYAJ9u
zHHCxwGUtiQCH6RwYscRBOS0QBjKsYGqCSk1lMpQDoxs0okjaVjVEABCVBIfc6CwccBxADwxCaiF
VEHqBosAqhsnMdiaUABoDCsJIDq40YmZkIJCBgP2/VMiIAxWd4kkTsr6SA7W3ndBJMPJai8naSBQ
Lk0zxKalvZo00kO8DgXAxID2UmLJHARLtAAYsdorCQ0NS/TBHcMytwkdFb8JgyHDYuKJCx2/OcQm
mFhCSScM73tfFNRhMsoLJY+UwBeneAKHly7fZ0EdqOxQc0UAvFBGBT0/JEAD9SWN0XEBAQA7
"""
        wrong = """R0lGODlhQABAAOexAAAAAAEAAAIAAAMAAAQAAAUAAAYAAAgAAAkAAAoAAAwAAA0AAA4AAA8AABAA
ABEAABIAABMAABQAABUAABYAABcAABgAABkAABoAABsAABwAAB0AAB4AAB8AACAAACEAACIAACMA
ACQAACUAACYAACgAACkAACoAACsAACwAAC0AAC4AADEAADMAADQAADUAADYAADgAADkAADoAADsA
ADwAAD0AAD4AAD8AAEEAAEIAAEQAAEUAAEkAAEoAAEsAAFQAAFUAAFgAAFkAAF0AAF8AAGEAAGIA
AGQAAGcAAGgAAGoAAGsAAG0AAG4AAG8AAHAAAHMAAHgAAHsAAHwAAIEAAIYAAIoAAI4AAJMAAJQA
AJUAAJYAAJcAAJgAAJkAAJoAAJsAAJwAAJ0AAJ4AAKAAAKEAAKQAAKcAAKgAAKkAAKoAAK0AAK4A
AK8AALAAALEAALMAALUAALcAALgAALkAALoAALsAAL4AAL8AAMAAAMEAAMQAAMUAAMYAAMgAAMkA
AMoAAMwAAM0AAM4AAM8AANAAANEAANIAANMAANQAANUAANYAANcAANgAANkAANoAANsAAN0AAN4A
AOAAAOEAAOIAAOMAAOQAAOYAAOgAAOkAAOoAAOwAAO0AAO4AAO8AAPAAAPEAAPIAAPMAAPQAAPUA
APYAAPcAAPgAAPkAAPoAAPsAAPwAAP0AAP4AAP8AAP//////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////yH+EUNyZWF0ZWQgd2l0aCBH
SU1QACH5BAEKAP8ALAAAAABAAEAAAAj+AP8JHEhwIAAABRMqXLjwIMOHCQFAgIAQosWGFjRUvNhQ
A5sxDTZyvAggwhpAK0SOFAigwxxXo7aEXGmxZBlSqwbFUMmx5Z1To0qN4oKAJ02DCsiQEmqKUA2j
DwFsoFOKFKlRpE55CQB1JQABZE5dtVqqEIyuES28STXW6ihWXxweNQhAzCqsVq+eMpQCrUEKamCN
wpt3VKsvBPwyBEDASyvChVcdKuEXQIU0giEXVtVFgWKFCbKo0lyY1SEVXQFcaJM5r+u8pbY4+ExQ
AZbXuK+uQjTDKAAMckaTdh00pueRCK6IEpqb+ClEOVSqliN0+OugpbgkrinASinmzYn+l0KEYyMA
Cm3EWseNVZUXuQ0BVFnVNvxrU4peIATQ4AzM9c0ZtlVqVAhmX4CpKBLCQR8UYkp9BxLHShdFKUTA
FDBFyB4ppugBwn4m8CGWhuydIpNKBkxhCoD2mXLHhwad8MeKJLKnBQMbFSAFKODVeJUpe4ggHQiH
0OjjVUJtcQBCAkTBI4u5jXLKIBz4VsEjQB05FipdHLTEKdUdKWUjE6QmQSMPQskeK1sQ4QqEGmJl
SiMSVKbBIOppOYoqj6lJXFaFbPAZACT0kaeYcEaI1SmBnEDbPwCgYKiWlOZ1iiAsPMoSCYMYWSmJ
QTGS0lwAaNBIlp8qWoolJGhaEAD+EjziaapRlpIJjHMZVEGRiaYqJyWU5foqCH8cSuuWjrTgalQn
iHisa6csYsOyEAFgAiCzVhqUJOUJG5UHiWSL6Ca9eVstBYw8mKonZ5lbUxOspJoKGvC5q1AASbDi
Z4CrgFGhvQkN0ESatI6CChgPUAvRAFB40uOxYkSg8EIBONGJuNpWZcYCE7+qxFKDPesWh2psZy4A
R7TS67F7viFAxwAg8UrIIrO3ShwJKCwAE6nQXDN7qLxBwbIDPBHKyj9bZUobGq0kwBOdPJz0dUvB
cQFtADARSpg+yrlvYRzaMVtNSLDlM6ikdJLu1yOfwse/DR0xM9tYlcLJCxIgQrD+mKgAMtO9SvSJ
6CmUTAsAB37s3TUqfmTA0wBOjKwlKpDsUBGheIyo5yl6tEoQw1Gz/eMkPIgEwAh5oKrlKXl4/s8B
DWN8IFaadPtqBn2gIrqcf6BwUAaCCIdoKDs1xMAfPW+uiQv7vaCIumiX8ol+USHg7NelYPKDeTgg
InWAWWFSbrUN1KG4fVhVIoR0OSCiOvioRKID1mpVxWJQlhDhmwyI3HXgKZEonVcywAboBegUmghC
alRwCH0FKHvzOwoAJuAG3R3QEz2oTAkM4T+qfWJ8EkwAHDronE9EsCYpKMT7sBIK6gkLAAFow2jE
wwkfPAoAMCBEVcZiCk0U72RWBEiD4jAxBFcBgAaEoBEqJmE7dwFgATcRSikuYQRqASAGg1DFKSAh
QIBBCgJh4NAmijAxAKxAEJiwnBcN4gAwdAIIHYNUB24Qx8U8QFn2guEaI/KZgAAAOw=="""
        self.correct_img = PhotoImage(data=correct)
        self.wrong_img = PhotoImage(data=wrong)
        self.entry = Entry(self.parent, width=15, 
                           font=('Helvetica', 20, 'normal'), justify=CENTER)
        self.entry.bind("<Return>", lambda x:self.buttonSubmit.invoke())
        self.buttonNext = Button(self.parent, width=10, text="Next Word",
                            command=self.next_word, state=DISABLED)
        self.buttonSubmit = Button(self.parent, width=10, text="Submit",
                              command=self.submit_word)
        buttonReplay = Button(self.parent, width=10, text="Repeat Word",
                              command=self.replay_word)
        self.game_canvas = Canvas(self, width=600, height=250, bg="#FFFFFF")
        self.word_display = self.game_canvas.create_text((300, 105), text="?",
                           font=("Helvetica", 50, "bold"), fill="#004183")
        self.progress_display = self.game_canvas.create_text((593, 5),
                                text="%d/%d"%(1, self.parent.list_length),
                                font=("Helvetica", 25, "bold"), anchor=NE)
        self.timer_display = self.game_canvas.create_text(10, 5, anchor=NW,
                                                        font=("Helvetica", 25))
        self.progress_bar = ProgressBar(self, width=300,
                                       increments=len(self.parent.current_list.words))
        self.game_canvas.create_window(500, 10, anchor=NE, window=self.progress_bar)
        self.game_canvas.create_window(300, 180, window=self.entry)
        self.game_canvas_image = self.game_canvas.create_image(500, 170)
        self.game_canvas.create_window(150, 230, window=buttonReplay)
        self.game_canvas.create_window(300, 230, window=self.buttonSubmit)
        self.game_canvas.create_window(450, 230, window=self.buttonNext)
        self.game_canvas.pack()
        
    def start(self):
#.........这里部分代码省略.........
开发者ID:Soulreaverm,项目名称:SE206Project,代码行数:103,代码来源:GameFrame.py

示例13: EvaluateSiteReadiness

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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

示例14: ProduceSiteReadinessHTMLViews

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [as 别名]
    def ProduceSiteReadinessHTMLViews(self):
        print "\nProducing Site Readiness HTML view\n"
        colspans1 = str(self.cinfo.daysToShow + 1)
        colspans2 = str(self.cinfo.daysToShow + 1)
        colspans22 = str(self.cinfo.daysToShow + 2)
        colspans3 = str(self.cinfo.daysSC)
        colspans4 = str(self.cinfo.daysSC)
        colspans5 = str(self.cinfo.daysToShow - self.cinfo.daysSC)

        dw = 45
        mw = 325

        tablew = str((self.cinfo.daysToShow) * dw + mw)
        dayw = str(dw)
        metricw = str(mw)
        daysw = str((self.cinfo.daysToShow) * dw)
        scdaysw1 = str((self.cinfo.daysSC) * dw)
        scdaysw = str((self.cinfo.daysSC) * dw)

        filehtml = self.htmlOutDir + "/SiteReadinessReport_" + self.tinfo.timestamphtml + ".html"
        fileHandle = open(filehtml, "w")

        fileHandle.write(
            '<html><head><title>CMS Site Readiness</title><link type="text/css" rel="stylesheet" href="'
            + self.options.css
            + '/style-css-reports.css"/></head>\n'
        )
        fileHandle.write("<body><center>\n")
        fileHandle.write('<h1 style="line-height:200%">Site Readiness Report</h1>')

        sitesit = self.matrices.readiValues.keys()
        sitesit.sort()

        prog = ProgressBar(0, 100, 77)
        for sitename in sitesit:
            prog.increment(100.0 / len(sitesit))
            if not self.SkipSiteOutput(sitename):
                fileHandle.write('<a name="' + sitename + '"></a>\n\n')
                fileHandle.write("<div id=para-" + sitename + ">\n")

                fileHandle.write('<table border="0" cellspacing="0" class=stat>\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>\n")
                fileHandle.write('<td width="' + metricw + '"></td>\n')
                fileHandle.write(
                    '<td width="'
                    + daysw
                    + '" colspan='
                    + colspans1
                    + ' bgcolor=darkblue><div id="site">'
                    + sitename
                    + "</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 height=7><td width=" + metricw + "></td>\n")
                fileHandle.write("<td width=" + daysw + " colspan=" + colspans1 + "></td></tr>\n")

                dates = self.matrices.dailyMetrics[sitename].keys()
                dates.sort()

                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")
                fileHandle.write(
                    "<td width="
                    + scdaysw1
                    + " colspan="
                    + colspans3
                    + '><div id="daily-metric-header">Site Readiness Status: </div></td>\n'
                )

                igdays = 0
                for datesgm in dates:  # write out 'Site Readiness Status' line
                    igdays += 1
                    if (self.cinfo.days - igdays) > (self.cinfo.daysToShow - self.cinfo.daysSC):
                        continue

                    if not self.matrices.readiValues[sitename].has_key(datesgm):
                        continue
                    state = self.matrices.readiValues[sitename][datesgm]
                    datesgm1 = datesgm[8:10]
                    c = datetime.datetime(*time.strptime(datesgm, "%Y-%m-%d")[0:5])
                    fileHandle.write(
                        '<td width="'
                        + dayw
                        + '" bgcolor='
                        + self.cinfo.colors[state]
                        + '><div id="daily-metric">'
                        + state
                        + "</div></td>\n"
                    )

#.........这里部分代码省略.........
开发者ID:gastonlp,项目名称:SiteReadiness,代码行数:103,代码来源:OutputWriter.py

示例15: GetDowntimes

# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import increment [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


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