def buildCsvFileName(infos): """ @summary: Builds and returns the file name to use for the csv file. @param infos: _CvsInfos instance containing the required information to build up the file name. @return: Return the built up file name. """ global _ StatsDateLib.setLanguage(infos.outputLanguage) paths = StatsPaths() paths.setPaths(infos.outputLanguage) machinesStr = str(infos.machinesForLabels).replace('[', '').replace( ']', '').replace(',', '').replace("'", "").replace('"', '').replace(' ', '') currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( StatsDateLib.getSecondsSinceEpoch(infos.start)) currentWeek = time.strftime( "%W", time.gmtime(StatsDateLib.getSecondsSinceEpoch(infos.start))) fileName = paths.STATSCSVFILES if infos.span == "daily": fileName = fileName + "/" + _( "daily/") + infos.fileType + "/%s/%s/%s/%s.csv" % ( machinesStr, currentYear, currentMonth, currentDay) elif infos.span == "weekly": fileName = fileName + "/" + _( "weekly/") + infos.fileType + "/%s/%s/%s.csv" % ( machinesStr, currentYear, currentWeek) elif infos.span == "monthly": fileName = fileName + "/" + _( "monthly/") + infos.fileType + "/%s/%s/%s.csv" % ( machinesStr, currentYear, currentMonth) elif infos.span == "yearly": fileName = fileName + "/" + _( "yearly/") + infos.fileType + "/%s/%s.csv" % (machinesStr, currentYear) StatsDateLib.setLanguage(LanguageTools.getMainApplicationLanguage()) return fileName
def buildCsvFileName( infos ): """ @summary: Builds and returns the file name to use for the csv file. @param infos: _CvsInfos instance containing the required information to build up the file name. @return: Return the built up file name. """ global _ StatsDateLib.setLanguage(infos.outputLanguage) paths = StatsPaths() paths.setPaths( infos.outputLanguage ) machinesStr = str(infos.machinesForLabels).replace('[','').replace( ']','' ).replace(',', '').replace("'","").replace( '"','').replace( ' ','' ) currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( StatsDateLib.getSecondsSinceEpoch (infos.start) ) currentWeek = time.strftime( "%W", time.gmtime( StatsDateLib.getSecondsSinceEpoch (infos.start) ) ) fileName = paths.STATSCSVFILES if infos.span == "daily": fileName = fileName + "/" + _("daily/") + infos.fileType + "/%s/%s/%s/%s.csv" %( machinesStr, currentYear, currentMonth, currentDay ) elif infos.span == "weekly": fileName = fileName + "/" + _("weekly/") + infos.fileType + "/%s/%s/%s.csv" %( machinesStr, currentYear, currentWeek ) elif infos.span == "monthly": fileName = fileName + "/" + _("monthly/") + infos.fileType + "/%s/%s/%s.csv" %( machinesStr, currentYear, currentMonth ) elif infos.span == "yearly": fileName = fileName + "/" + _("yearly/") + infos.fileType + "/%s/%s.csv" %( machinesStr, currentYear ) StatsDateLib.setLanguage( LanguageTools.getMainApplicationLanguage() ) return fileName
def printWebPage(self, rxNames, txNames): """ @summary : Generates a web page based on all the rxnames and tx names that have run during the past x years. @param rxNames: List of sources for which to write links to their yearly graphics. @param txNames: List of clients for which to write links to their yearly graphics. @precondition: global _ translator must be set prior to calling this function. @notes : Only links to available graphics will be displayed. @return : None """ global _ rxNamesArray = rxNames.keys() txNamesArray = txNames.keys() rxNamesArray.sort() txNamesArray.sort() # Redirect output towards html page to generate. if not os.path.isdir(self.pathsTowardsOutputFiles.STATSWEBPAGESHTML): os.makedirs(self.pathsTowardsOutputFiles.STATSWEBPAGESHTML) fileHandle = open( "%syearlyGraphs_%s.html" % (self.pathsTowardsOutputFiles.STATSWEBPAGESHTML, self.displayedLanguage), "w" ) fileHandle.write( """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <link rel="stylesheet" href="../scripts/js_%s/windowfiles/dhtmlwindow.css" type="text/css" /> <script type="text/javascript" src="../scripts/js_%s/windowfiles/dhtmlwindow.js"> This is left here to give credit to the original creators of the dhtml script used for the group pop ups: /*********************************************** * DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for legal use. * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> """ % (self.displayedLanguage, self.displayedLanguage) + """ <script type="text/javascript"> var descriptionWindow=dhtmlwindow.open("description", "inline", "description", "Description", "width=900px,height=120px,left=150px,top=10px,resize=1,scrolling=0", "recal") descriptionWindow.hide() </script> <head> <title> PX Graphics </title> <script> counter =0; function wopen(url, name, w, h){ // This function was taken on www.boutell.com w += 32; h += 96; counter +=1; var win = window.open(url, counter, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no'); win.resizeTo(w, h); win.focus(); } </script> <script> function showSourceHelpPage(){ var sourceHelpPage = dhtmlwindow.open("sourceHelpPage", "iframe", "helpPages/source_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'source'") + """", "width=875px,height=100px,resize=1,scrolling=1,center=1", "recal") sourceHelpPage.moveTo("middle", "middle"); } function showBytecountHelpPage(){ var byteCountHelpPage = dhtmlwindow.open("byteCount", "iframe", "helpPages/byteCount_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'byteCount'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") byteCountHelpPage.moveTo("middle", "middle"); } function showClientHelpPage(){ var clientHelpPage = dhtmlwindow.open("client", "iframe", "helpPages/client_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'client'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") .moveTo("middle", "middle"); } function showErrorsHelpPage(){ var errorsHelpPage = dhtmlwindow.open("errors", "iframe", "helpPages/errors_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'errors'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") errorsHelpPage.moveTo("middle", "middle"); } function showFilecountHelpPage(){ var fileCountHelpPage = dhtmlwindow.open("fileCount", "iframe", "helpPages/fileCount_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'filecount'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") fileCountHelpPage.moveTo("middle", "middle"); } function showFilesOverMaxLatencyHelpPage(){ var filesOverMaxLatencyHelpPage = dhtmlwindow.open("filesOverMaxLatency", "iframe", "helpPages/filesOverMaxLatency_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'filesOverMaxLatency'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") filesOverMaxLatencyHelpPage.moveTo("middle", "middle"); } function showLatencyHelpPage(){ var latencyHelpPage = dhtmlwindow.open("latency", "iframe", "helpPages/latency_%s.html" """ % self.displayedLanguage + """, " """ + _("Definition of 'latency'") + """" , "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") latencyHelpPage.moveTo("middle", "middle"); } </script> <STYLE> <!-- A{text-decoration:none} --> </STYLE> <style type="text/css"> div.left { float: left; } div.right {float: right; } </style> <style type="text/css"> a.blackLinks{ color: #000000; } div.tableContainer { width: 95%; /* table width will be 99% of this*/ height: 275px; /* must be greater than tbody*/ overflow: auto; margin: 0 auto; } table.cssTable { width: 99%; /*100% of container produces horiz. scroll in Mozilla*/ border: none; background-color: #f7f7f7; table-layout: fixed; } table.cssTable>tbody { /* child selector syntax which IE6 and older do not support*/ overflow: auto; height: 225px; overflow-x: hidden; } thead tr { position:relative; } thead td, thead th { text-align: center; font-size: 14px; background-color:"#006699"; color: steelblue; font-weight: bold; border-top: solid 1px #d8d8d8; } td.cssTable { color: #000; padding-right: 2px; font-size: 12px; text-align: left; border-bottom: solid 1px #d8d8d8; border-left: solid 1px #d8d8d8; } tfoot td { text-align: center; font-size: 11px; font-weight: bold; background-color: papayawhip; color: steelblue; border-top: solid 2px slategray; } td:last-child {padding-right: 20px;} /*prevent Mozilla scrollbar from hiding cell content*/ </style> </head> <body text="#000000" link="#FFFFFF" vlink="000000" bgcolor="#FFF4E5" > <br> <table width = "100%"> <tr width = "100%"> <div class="left"><b><font size="5">""" + _("Yearly graphics for RX sources from MetPx.") + """ </font><font size = "2">""" + _("*updated monthly") + """</font></b></div> """ ) oneFileFound = False for year in self.years: parameters = StatsConfigParameters() parameters.getAllParameters() machinesStr = ( str(parameters.sourceMachinesTags) .replace("[", "") .replace("]", "") .replace(",", "") .replace("'", "") .replace('"', "") .replace(" ", "") ) currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = self.pathsTowardsGraphics.STATSCSVFILES + _("yearly/rx/%s/%s.csv") % (machinesStr, currentYear) webLink = _("csvFiles/yearly/rx/%s/%s.csv") % (machinesStr, currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): if oneFileFound == False: fileHandle.write( "<div class='right'><font size='2' color='black'" + _("CSV files") + " : " ) oneFileFound = True fileHandle.write("""<a href="%s" class="blackLinks">%.4s.csv </a>""" % (webLink, currentYear)) if oneFileFound == True: fileHandle.write( """ </font> </div> """ ) fileHandle.write( """ </tr> </td> </table> <br> <br> <div class="tableContainer"> <table class="cssTable"> <thead> <tr> <td bgcolor="#006699" class="cssTable"> <font color = "white"> <center> """ + _("Sources") + """ <br> <a target ="popup" href="#" onClick="showSourceHelpPage(); return false;"> ? </a> <center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _("Display the total of bytes received every day of the week for each sources.") + """ "> <font color = "white"> <center> """ + _("Bytecount") + """ <br> <a target ="popup" href="#" onClick="showBytecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _("Display the total of files received every day of the week for each sources.") + """ "> <font color = "white"> <center> """ + _("Filecount") + """ <br> <a target ="popup" href="#" onClick="showFilecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title = " """ + _( "Display the total of errors that occured during the receptions for every day of the week for each sources." ) + """ "> <font color = "white"> <center> """ + _("Errors") + """ <br> <a target ="popup" href="#" onClick="showErrorsHelpPage(); return false;"> ? </a> </center> </font> </td> </tr> </thead> <tbody> """ ) for rxName in rxNamesArray: if rxNames[rxName] == "": fileHandle.write("""<tr> <td bgcolor="#99FF99" class="cssTable"> %s </td> """ % (rxName)) fileHandle.write("""<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) else: machineName = self.getMachineNameFromDescription(rxNames[rxName]) fileHandle.write( """<tr> <td bgcolor="#99FF99" class="cssTable"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ % (rxName, rxNames[rxName].replace("'", "").replace('"', ""), machineName) ) fileHandle.write("""<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/") % (rxName) + _("bytecount/%s.png") % str(currentYear) ) webLink = _("archives/yearly/rx/%s/") % (rxName) + _("bytecount/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (rxName, webLink, time.strftime("%Y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/") % (rxName) + _("filecount/%s.png") % str(currentYear) ) webLink = _("archives/yearly/rx/%s/") % (rxName) + _("filecount/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (rxName, webLink, time.strftime("%Y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/") % (rxName) + _("errors/%s.png") % str(currentYear) ) webLink = _("archives/yearly/rx/%s/") % (rxName) + _("errors/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (rxName, file, time.strftime("%Y", time.gmtime(year))) ) fileHandle.write("</td></tr>") fileHandle.write( """ </tbody> </table> </div> <br> <table width = "100%"> <tr width = "100%"> <div class="left"><b><font size="5">""" + _("Yearly graphics for TX clients from MetPx.") + """ </font><font size = "2">""" + _("*updated monthly") + """</font></b></div> """ ) oneFileFound = False for year in self.years: parameters = StatsConfigParameters() parameters.getAllParameters() machinesStr = ( str(parameters.sourceMachinesTags) .replace("[", "") .replace("]", "") .replace(",", "") .replace("'", "") .replace('"', "") .replace(" ", "") ) currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = self.pathsTowardsGraphics.STATSCSVFILES + _("yearly/tx/%s/%s.csv") % (machinesStr, currentYear) webLink = _("csvFiles/yearly/tx/%s/%s.csv") % (machinesStr, currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) print file if os.path.isfile(file): if oneFileFound == False: fileHandle.write( "<div class='right'><font size='2' color='black'>" + _("CSV files") + " : " ) oneFileFound = True fileHandle.write("""<a href="%s" class="blackLinks">%.4s.csv </a>""" % (webLink, currentYear)) if oneFileFound == True: fileHandle.write( """ </font> </div> """ ) fileHandle.write( """ </tr> </td> </table> <br> <br> <div class="tableContainer"> <table class="cssTable" > <thead> <tr> <td bgcolor="#006699" class="cssTable"> <font color = "white"> <center> """ + _("Clients") + """ <br> <a target ="popup" href="#" onClick="showClientHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _("Display the taverage latency of file transfers for every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Latency") + """ <br> <a target ="popup" href="#" onClick="showLatencyHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _( "Display the total number of files for wich the latency was over 15 seconds for every day of the week for each clients." ) + """> <font color = "white"> <center> """ + _("Files Over Max. Lat.") + """ <br> <a target ="popup" href="#" onClick="showFilesOverMaxLatencyHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _("Display the total of bytes transfered every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Bytecount") + """ <br> <a target ="popup" href="#" onClick="showBytecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _("Display the total of files transferred every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Filecount") + """ <br> <a target ="popup" href="#" onClick="showFilecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _( "Display the total of errors that occured during file transfers every day of the week for each clients." ) + """> <font color = "white"> <center> """ + _("Errors") + """ <br> <a target ="popup" href="#" onClick="showErrorsHelpPage(); return false;"> ? </a> </center> </font> </td> </tr> </thead> <tbody> """ ) for txName in txNamesArray: if txNames[txName] == "": fileHandle.write(""" <tr> <td bgcolor="#99FF99" class="cssTable">%s</td> """ % (txName)) fileHandle.write("""<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) else: machineName = self.getMachineNameFromDescription(txNames[txName]) fileHandle.write( """<tr> <td bgcolor="#99FF99" class="cssTable"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ % (txName, txNames[txName].replace("'", "").replace('"', ""), machineName) ) fileHandle.write("""<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/") % (txName) + _("latency/%s.png") % str(currentYear) ) webLink = _("archives/yearly/tx/%s/") % (txName) + _("latency/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (txName, webLink, time.strftime("%y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF" class="cssTable" >""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/") % (txName) + _("filesOverMaxLatency/%s.png") % str(currentYear) ) webLink = _("archives/yearly/tx/%s/") % (txName) + _("filesOverMaxLatency/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (txName, webLink, time.strftime("%y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF" class="cssTable" >""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/") % (txName) + _("bytecount/%s.png") % str(currentYear) ) webLink = _("archives/yearly/tx/%s/") % (txName) + _("bytecount/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (txName, webLink, time.strftime("%y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF">""" + _("Years") + """ : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/") % (txName) + _("filecount/%s.png") % str(currentYear) ) webLink = _("archives/yearly/tx/%s/") % (txName) + _("filecount/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (txName, webLink, time.strftime("%y", time.gmtime(year))) ) fileHandle.write("</td>") fileHandle.write(""" <td bgcolor="#66CCFF" class="cssTable" >Years : """) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime(year) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = ( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/") % (txName) + _("errors/%s.png") % str(currentYear) ) webLink = _("archives/yearly/tx/%s/") % (txName) + _("errors/%s.png") % str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>""" % (txName, webLink, time.strftime("%y", time.gmtime(year))) ) fileHandle.write("</td></tr>") fileHandle.write( """ </tbody> </table> </div> </body> </html> """ ) fileHandle.close()
def printWebPage(self, rxNames, txNames): """ @summary : Prints out a daily web page with the content based on the specified parameters. @param rxNames: List of rx for which to display the graphics @param txNames: List of rx for which to display the graphics @precondition: global _ translator must be set prior to calling this function. @note : Only links to available graphics will be displayed. """ global _ StatsDateLib.setLanguage(self.displayedLanguage) rxNamesArray = rxNames.keys() txNamesArray = txNames.keys() rxNamesArray.sort() txNamesArray.sort() #Redirect output towards html page to generate. if not os.path.isdir(self.pathsTowardsOutputFiles.STATSWEBPAGESHTML): os.makedirs(self.pathsTowardsOutputFiles.STATSWEBPAGESHTML) fileHandle = open( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML + "dailyGraphs_%s.html" % self.displayedLanguage, 'w') fileHandle.write(""" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <link rel="stylesheet" href="../scripts/js_%s/windowfiles/dhtmlwindow.css" type="text/css" /> <script type="text/javascript" src="../scripts/js_%s/windowfiles/dhtmlwindow.js"> This is left here to give credit to the original creators of the dhtml script used for the group pop ups: /*********************************************** * DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for legal use. * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> """ % (self.displayedLanguage, self.displayedLanguage) + """ <script type="text/javascript"> var descriptionWindow=dhtmlwindow.open("description", "inline", "description", "Description", "width=900px,height=120px,left=150px,top=10px,resize=1,scrolling=0", "recal") descriptionWindow.hide() </script> <head> <title> PX Graphics </title> </head> <script> counter =0; function wopen(url, name, w, h){ // This function was taken on www.boutell.com w += 32; h += 96; counter +=1; var win = window.open(url, counter, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no'); win.resizeTo(w, h); win.focus(); } </script> <script> function showSourceHelpPage(){ var sourceHelpPage = dhtmlwindow.open("sourceHelpPage", "iframe", "helpPages/source_%s.html", "Definition of 'source'", "width=875px,height=100px,resize=1,scrolling=1,center=1", "recal") sourceHelpPage.moveTo("middle", "middle"); }""" % (self.displayedLanguage) + """ function showClientHelpPage(){ var clientHelpPage = dhtmlwindow.open("client", "iframe", "helpPages/client_%s.html", "Definition of 'client'", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") .moveTo("middle", "middle"); }""" % (self.displayedLanguage) + """ </script> <STYLE> <!-- A{text-decoration:none} --> </STYLE> <style type="text/css"> div.left { float: left; } div.right {float: right; } </style> <style type="text/css"> div.tableContainer { width: 95%; /* table width will be 99% of this*/ height: 275px; /* must be greater than tbody*/ overflow: auto; margin: 0 auto; } table { width: 99%; /*100% of container produces horiz. scroll in Mozilla*/ border: none; background-color: #f7f7f7; table-layout: fixed; } table>tbody { /* child selector syntax which IE6 and older do not support*/ overflow: auto; height: 225px; overflow-x: hidden; } thead tr { position:relative; } thead td, thead th { text-align: center; font-size: 14px; background-color:"#006699"; color: steelblue; font-weight: bold; border-top: solid 1px #d8d8d8; } td { color: #000; padding-right: 2px; font-size: 12px; text-align: left; border-bottom: solid 1px #d8d8d8; border-left: solid 1px #d8d8d8; } tfoot td { text-align: center; font-size: 11px; font-weight: bold; background-color: papayawhip; color: steelblue; border-top: solid 2px slategray; } td:last-child {padding-right: 20px;} /*prevent Mozilla scrollbar from hiding cell content*/ </style> <body text="#000000" link="#FFFFFF" vlink="000000" bgcolor="#FFF4E5" > <h2>""" + _("Daily graphics for RX sources from MetPx.") + """ <font size = "2">""" + _("*updated hourly") + """</font></h2> <div class="tableContainer"> <table> <thead> <tr> <td bgcolor="#006699"> <div class = "rxTableEntry"> <font color = "white"> <center> Sources <br> <a target ="popup" href="#" onClick="showSourceHelpPage(); return false;"> ? </a> </center> </font> </div> </td> <td bgcolor="#006699"> <font color = "white">""" + _("List of available daily graphics.") + """</font> </td> </tr> </thead> <tbody> """) for rxName in rxNamesArray: if rxNames[rxName] == "": fileHandle.write("""<tr> <td bgcolor="#99FF99"> %s</td> """ % (rxName)) fileHandle.write("""<td bgcolor="#66CCFF"> """ + _("Days") + """ : """) else: machineName = self.getMachineNameFromDescription( rxNames[rxName]) fileHandle.write( """<tr> <td bgcolor="#99FF99"><div class="left"> %s</div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ % (rxName, rxNames[rxName].replace("'", "").replace( '"', '').replace(",", ", "), machineName)) fileHandle.write("""<td bgcolor="#66CCFF"> """ + _("Days") + """ : """) for day in self.days: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( day) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _( "daily/rx/%s/") % (rxName) + str(currentYear) + "/" + str( currentMonth) + "/" + str(currentDay) + ".png" webLink = _("archives/daily/rx/%s/") % (rxName) + str( currentYear) + "/" + str(currentMonth) + "/" + str( currentDay) + ".png" _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write("""<a target ="%s" href="%s">""" % (rxName, webLink) + "%s" % StatsDateLib.getDayOfTheWeek(day) + """ </a>""") else: pass fileHandle.write("""</td></tr>""") fileHandle.write(""" </tbody> </table> </div> <h2>""" + _("Daily graphics for TX clients from MetPx.") + """ <font size = "2">""" + _("*updated hourly") + """</font></h2> <div class="tableContainer"> <table> <thead> <tr> <td bgcolor="#006699"> <div class = "txTableEntry"> <font color = "white"> <center> Clients <br> <a target ="popup" href="#" onClick="showClientHelpPage(); return false;"> ? </a> <center> </font> </div> </td> <td bgcolor="#006699"> <div class = "txTableEntry"> <font color = "white">""" + _("List of available daily graphics.") + """</font> </div> </td> </tr> </thead> <tbody> """) for txName in txNamesArray: if txNames[txName] == "": fileHandle.write("""<tr> <td bgcolor="#99FF99"> %s</td> """ % (txName)) fileHandle.write( """<td bgcolor="#66CCFF"><div class = "txTableEntry"> """ + _("Days") + """ : """) else: machineName = self.getMachineNameFromDescription( txNames[txName]) fileHandle.write( """<tr> <td bgcolor="#99FF99"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ % (txName, txNames[txName].replace("'", "").replace( '"', '').replace(",", ", "), machineName)) fileHandle.write("""<td bgcolor="#66CCFF"> """ + _("Days") + """ : """) for day in self.days: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( day) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _( "/daily/tx/%s/") % (txName) + str(currentYear) + "/" + str( currentMonth) + "/" + str(currentDay) + ".png" webLink = _("archives/daily/tx/%s/") % (txName) + str( currentYear) + "/" + str(currentMonth) + "/" + str( currentDay) + ".png" _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage) if os.path.isfile(file): fileHandle.write("""<a target ="%s" href="%s">""" % (rxName, webLink) + "%s" % StatsDateLib.getDayOfTheWeek(day) + """ </a>""") else: pass fileHandle.write("</td></tr>") fileHandle.write(""" </tbody> </table> </body> </html> """) fileHandle.close()
def printWebPage( self, rxNames, txNames ): """ @summary : Generates a web page based on all the rxnames and tx names that have run during the past x years. @param rxNames: List of sources for which to write links to their yearly graphics. @param txNames: List of clients for which to write links to their yearly graphics. @precondition: global _ translator must be set prior to calling this function. @notes : Only links to available graphics will be displayed. @return : None """ global _ rxNamesArray = rxNames.keys() txNamesArray = txNames.keys() rxNamesArray.sort() txNamesArray.sort() #Redirect output towards html page to generate. if not os.path.isdir( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML ): os.makedirs( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML ) fileHandle = open( "%syearlyGraphs_%s.html" %(self.pathsTowardsOutputFiles.STATSWEBPAGESHTML, self.displayedLanguage) , 'w' ) fileHandle.write( """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <link rel="stylesheet" href="../scripts/js_%s/windowfiles/dhtmlwindow.css" type="text/css" /> <script type="text/javascript" src="../scripts/js_%s/windowfiles/dhtmlwindow.js"> This is left here to give credit to the original creators of the dhtml script used for the group pop ups: /*********************************************** * DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for legal use. * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> """%( self.displayedLanguage, self.displayedLanguage ) + """ <script type="text/javascript"> var descriptionWindow=dhtmlwindow.open("description", "inline", "description", "Description", "width=900px,height=120px,left=150px,top=10px,resize=1,scrolling=0", "recal") descriptionWindow.hide() </script> <head> <title> PX Graphics </title> <script> counter =0; function wopen(url, name, w, h){ // This function was taken on www.boutell.com w += 32; h += 96; counter +=1; var win = window.open(url, counter, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no'); win.resizeTo(w, h); win.focus(); } </script> <script> function showSourceHelpPage(){ var sourceHelpPage = dhtmlwindow.open("sourceHelpPage", "iframe", "helpPages/source_%s.html" """ %self.displayedLanguage + """, " """ + _("Definition of 'source'") + """", "width=875px,height=100px,resize=1,scrolling=1,center=1", "recal") sourceHelpPage.moveTo("middle", "middle"); } function showBytecountHelpPage(){ var byteCountHelpPage = dhtmlwindow.open("byteCount", "iframe", "helpPages/byteCount_%s.html" """ %self.displayedLanguage + """, " """ +_( "Definition of 'byteCount'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") byteCountHelpPage.moveTo("middle", "middle"); } function showClientHelpPage(){ var clientHelpPage = dhtmlwindow.open("client", "iframe", "helpPages/client_%s.html" """ %self.displayedLanguage + """, " """ +_( "Definition of 'client'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") .moveTo("middle", "middle"); } function showErrorsHelpPage(){ var errorsHelpPage = dhtmlwindow.open("errors", "iframe", "helpPages/errors_%s.html" """ %self.displayedLanguage + """, " """ +_( "Definition of 'errors'") +"""", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") errorsHelpPage.moveTo("middle", "middle"); } function showFilecountHelpPage(){ var fileCountHelpPage = dhtmlwindow.open("fileCount", "iframe", "helpPages/fileCount_%s.html" """ %self.displayedLanguage + """, " """ +_("Definition of 'filecount'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") fileCountHelpPage.moveTo("middle", "middle"); } function showFilesOverMaxLatencyHelpPage(){ var filesOverMaxLatencyHelpPage = dhtmlwindow.open("filesOverMaxLatency", "iframe", "helpPages/filesOverMaxLatency_%s.html" """ %self.displayedLanguage + """, " """ +_("Definition of 'filesOverMaxLatency'") + """", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") filesOverMaxLatencyHelpPage.moveTo("middle", "middle"); } function showLatencyHelpPage(){ var latencyHelpPage = dhtmlwindow.open("latency", "iframe", "helpPages/latency_%s.html" """ %self.displayedLanguage + """, " """ + _("Definition of 'latency'") + """" , "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") latencyHelpPage.moveTo("middle", "middle"); } </script> <STYLE> <!-- A{text-decoration:none} --> </STYLE> <style type="text/css"> div.left { float: left; } div.right {float: right; } </style> <style type="text/css"> a.blackLinks{ color: #000000; } div.tableContainer { width: 95%; /* table width will be 99% of this*/ height: 275px; /* must be greater than tbody*/ overflow: auto; margin: 0 auto; } table.cssTable { width: 99%; /*100% of container produces horiz. scroll in Mozilla*/ border: none; background-color: #f7f7f7; table-layout: fixed; } table.cssTable>tbody { /* child selector syntax which IE6 and older do not support*/ overflow: auto; height: 225px; overflow-x: hidden; } thead tr { position:relative; } thead td, thead th { text-align: center; font-size: 14px; background-color:"#006699"; color: steelblue; font-weight: bold; border-top: solid 1px #d8d8d8; } td.cssTable { color: #000; padding-right: 2px; font-size: 12px; text-align: left; border-bottom: solid 1px #d8d8d8; border-left: solid 1px #d8d8d8; } tfoot td { text-align: center; font-size: 11px; font-weight: bold; background-color: papayawhip; color: steelblue; border-top: solid 2px slategray; } td:last-child {padding-right: 20px;} /*prevent Mozilla scrollbar from hiding cell content*/ </style> </head> <body text="#000000" link="#FFFFFF" vlink="000000" bgcolor="#FFF4E5" > <br> <table width = "100%"> <tr width = "100%"> <div class="left"><b><font size="5">""" + _("Yearly graphics for RX sources from MetPx.") + """ </font><font size = "2">""" +_("*updated monthly") + """</font></b></div> """) oneFileFound = False for year in self.years: parameters = StatsConfigParameters( ) parameters.getAllParameters() machinesStr = str( parameters.sourceMachinesTags ).replace( '[','' ).replace( ']','' ).replace(',','').replace("'","").replace('"','').replace(" ","") currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSCSVFILES + _("yearly/rx/%s/%s.csv") %( machinesStr, currentYear ) webLink = _("csvFiles/yearly/rx/%s/%s.csv") %( machinesStr, currentYear ) _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): if oneFileFound == False: fileHandle.write( "<div class='right'><font size='2' color='black'" + _("CSV files") + " : " ) oneFileFound = True fileHandle.write( """<a href="%s" class="blackLinks">%.4s.csv </a>"""%( webLink,currentYear ) ) if oneFileFound == True : fileHandle.write( """ </font> </div> """ ) fileHandle.write(""" </tr> </td> </table> <br> <br> <div class="tableContainer"> <table class="cssTable"> <thead> <tr> <td bgcolor="#006699" class="cssTable"> <font color = "white"> <center> """ +_("Sources") + """ <br> <a target ="popup" href="#" onClick="showSourceHelpPage(); return false;"> ? </a> <center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _( "Display the total of bytes received every day of the week for each sources.") + """ "> <font color = "white"> <center> """ +_("Bytecount") + """ <br> <a target ="popup" href="#" onClick="showBytecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ + _( "Display the total of files received every day of the week for each sources.") + """ "> <font color = "white"> <center> """ +_("Filecount") +""" <br> <a target ="popup" href="#" onClick="showFilecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title = " """ + _( "Display the total of errors that occured during the receptions for every day of the week for each sources.") + """ "> <font color = "white"> <center> """ +_("Errors") + """ <br> <a target ="popup" href="#" onClick="showErrorsHelpPage(); return false;"> ? </a> </center> </font> </td> </tr> </thead> <tbody> """ ) for rxName in rxNamesArray : if rxNames[rxName] == "" : fileHandle.write( """<tr> <td bgcolor="#99FF99" class="cssTable"> %s </td> """ %(rxName)) fileHandle.write( """<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) else: machineName = self.getMachineNameFromDescription( rxNames[rxName] ) fileHandle.write( """<tr> <td bgcolor="#99FF99" class="cssTable"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ %(rxName, rxNames[rxName].replace("'","").replace('"',''), machineName)) fileHandle.write( """<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/")%( rxName ) + _("bytecount/%s.png") %str(currentYear) webLink = _("archives/yearly/rx/%s/")%( rxName ) + _("bytecount/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( rxName, webLink , time.strftime("%Y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/")%( rxName ) + _("filecount/%s.png") %str(currentYear) webLink = _("archives/yearly/rx/%s/")%( rxName ) + _("filecount/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( rxName, webLink , time.strftime("%Y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/rx/%s/")%( rxName ) + _("errors/%s.png") %str(currentYear) webLink = _("archives/yearly/rx/%s/")%( rxName ) + _("errors/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( rxName, file , time.strftime("%Y",time.gmtime(year) ) ) ) fileHandle.write( "</td></tr>" ) fileHandle.write( """ </tbody> </table> </div> <br> <table width = "100%"> <tr width = "100%"> <div class="left"><b><font size="5">""" +_("Yearly graphics for TX clients from MetPx.") + """ </font><font size = "2">""" + _("*updated monthly") + """</font></b></div> """) oneFileFound = False for year in self.years: parameters = StatsConfigParameters( ) parameters.getAllParameters() machinesStr = str( parameters.sourceMachinesTags ).replace( '[','' ).replace( ']','' ).replace(',','').replace("'","").replace('"','').replace(" ","") currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSCSVFILES + _("yearly/tx/%s/%s.csv") %( machinesStr, currentYear ) webLink = _("csvFiles/yearly/tx/%s/%s.csv") %( machinesStr, currentYear ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) print file if os.path.isfile( file ): if oneFileFound == False: fileHandle.write( "<div class='right'><font size='2' color='black'>" + _("CSV files") + " : " ) oneFileFound = True fileHandle.write( """<a href="%s" class="blackLinks">%.4s.csv </a>"""%( webLink,currentYear ) ) if oneFileFound == True : fileHandle.write( """ </font> </div> """ ) fileHandle.write( """ </tr> </td> </table> <br> <br> <div class="tableContainer"> <table class="cssTable" > <thead> <tr> <td bgcolor="#006699" class="cssTable"> <font color = "white"> <center> """ + _("Clients") + """ <br> <a target ="popup" href="#" onClick="showClientHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """ +_("Display the taverage latency of file transfers for every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Latency") + """ <br> <a target ="popup" href="#" onClick="showLatencyHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """+_("Display the total number of files for wich the latency was over 15 seconds for every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Files Over Max. Lat.") + """ <br> <a target ="popup" href="#" onClick="showFilesOverMaxLatencyHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """+_("Display the total of bytes transfered every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Bytecount") + """ <br> <a target ="popup" href="#" onClick="showBytecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """+_("Display the total of files transferred every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Filecount") + """ <br> <a target ="popup" href="#" onClick="showFilecountHelpPage(); return false;"> ? </a> </center> </font> </td> <td bgcolor="#006699" class="cssTable" title =" """+_("Display the total of errors that occured during file transfers every day of the week for each clients.") + """> <font color = "white"> <center> """ + _("Errors") + """ <br> <a target ="popup" href="#" onClick="showErrorsHelpPage(); return false;"> ? </a> </center> </font> </td> </tr> </thead> <tbody> """ ) for txName in txNamesArray : if txNames[txName] == "" : fileHandle.write( """ <tr> <td bgcolor="#99FF99" class="cssTable">%s</td> """ %(txName)) fileHandle.write( """<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) else: machineName = self.getMachineNameFromDescription( txNames[txName] ) fileHandle.write( """<tr> <td bgcolor="#99FF99" class="cssTable"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ %(txName, txNames[txName].replace("'","").replace('"',''), machineName )) fileHandle.write( """<td bgcolor="#66CCFF" class="cssTable">""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/")%( txName ) + _("latency/%s.png") %str(currentYear) webLink = _("archives/yearly/tx/%s/")%( txName ) + _("latency/%s.png")%str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( txName, webLink , time.strftime("%y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF" class="cssTable" >""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/")%( txName ) + _("filesOverMaxLatency/%s.png")%str(currentYear) webLink = _("archives/yearly/tx/%s/")%( txName ) + _("filesOverMaxLatency/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( txName, webLink , time.strftime("%y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF" class="cssTable" >""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/")%( txName ) + _("bytecount/%s.png") %str(currentYear) webLink = _("archives/yearly/tx/%s/")%( txName ) + _("bytecount/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( txName, webLink , time.strftime("%y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF">""" + _("Years") + """ : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/")%( txName ) + _("filecount/%s.png") %str(currentYear) webLink = _("archives/yearly/tx/%s/")%( txName ) + _("filecount/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( txName, webLink , time.strftime("%y",time.gmtime(year) ) ) ) fileHandle.write( "</td>" ) fileHandle.write( """ <td bgcolor="#66CCFF" class="cssTable" >Years : """ ) for year in self.years: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( year ) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("yearly/tx/%s/")%( txName ) + _("errors/%s.png") %str(currentYear) webLink = _("archives/yearly/tx/%s/")%( txName ) + _("errors/%s.png") %str(currentYear) _ = self.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">%s </a>"""%( txName, webLink , time.strftime("%y",time.gmtime(year) ) ) ) fileHandle.write( "</td></tr>" ) fileHandle.write( """ </tbody> </table> </div> </body> </html> """ ) fileHandle.close()
def createCopy( self, copyToArchive = True , copyToColumbo = True ): """ @summary : Creates a copy of the created image file so that it easily be used in px's columbo or other daily image program. @summary : If copies are to be needed for graphcis other than daily graphs, please modify this method accordingly! """ statsPaths = StatsPaths() statsPaths.setPaths(self.outputLanguage) _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.outputLanguage ) src = self.imageName if self.groupName != "": clientName = self.groupName else: clientName = "" if len( self.clientNames ) == 0: clientName = self.clientNames[0] else: for name in self.clientNames : clientName = clientName + name if name != self.clientNames[ len(self.clientNames) -1 ] : clientName = clientName + "-" StatsDateLib.setLanguage( self.outputLanguage ) # Makes sure month is in the right language. year, month, day = StatsDateLib.getYearMonthDayInStrfTime( StatsDateLib.getSecondsSinceEpoch( self.currentTime ) - 60 ) # -60 means that a graphic ending at midnight StatsDateLib.setLanguage( self.workingLanguage )# Sets language back to working language. # would be named after the rpevious day. if copyToArchive == True : destination = statsPaths.STATSGRAPHSARCHIVES + _("daily/%s/%s/") %( self.fileType, clientName ) + str(year) + "/" + str(month) + "/" + str(day) + ".png" if not os.path.isdir( os.path.dirname( destination ) ): os.makedirs( os.path.dirname( destination ), 0777 ) dirname = os.path.dirname( destination ) while( dirname != statsPaths.STATSGRAPHSARCHIVES[:-1] ):#[:-1] removes the last / character try: os.chmod( dirname, 0777 ) except: pass dirname = os.path.dirname(dirname) shutil.copy( src, destination ) try: os.chmod( destination, 0777 ) except: pass #print "cp %s %s " %( src, destination ) if copyToColumbo == True : destination = statsPaths.STATSGRAPHS + _("webGraphics/columbo/%s_%s.png") %(clientName,self.outputLanguage) if not os.path.isdir( os.path.dirname( destination ) ): os.makedirs( os.path.dirname( destination ), 0777 ) os.chmod( os.path.dirname( destination ), 0777 ) shutil.copy( src, destination ) try: os.chmod( destination, 0777 ) except: pass
def printWebPage( self, rxNames, txNames ): """ @summary : Prints out a daily web page with the content based on the specified parameters. @param rxNames: List of rx for which to display the graphics @param txNames: List of rx for which to display the graphics @precondition: global _ translator must be set prior to calling this function. @note : Only links to available graphics will be displayed. """ global _ StatsDateLib.setLanguage(self.displayedLanguage) rxNamesArray = rxNames.keys() txNamesArray = txNames.keys() rxNamesArray.sort() txNamesArray.sort() #Redirect output towards html page to generate. if not os.path.isdir( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML ): os.makedirs( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML ) fileHandle = open( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML +"dailyGraphs_%s.html" %self.displayedLanguage , 'w' ) fileHandle.write( """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <link rel="stylesheet" href="../scripts/js_%s/windowfiles/dhtmlwindow.css" type="text/css" /> <script type="text/javascript" src="../scripts/js_%s/windowfiles/dhtmlwindow.js"> This is left here to give credit to the original creators of the dhtml script used for the group pop ups: /*********************************************** * DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for legal use. * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ </script> """%(self.displayedLanguage, self.displayedLanguage) + """ <script type="text/javascript"> var descriptionWindow=dhtmlwindow.open("description", "inline", "description", "Description", "width=900px,height=120px,left=150px,top=10px,resize=1,scrolling=0", "recal") descriptionWindow.hide() </script> <head> <title> PX Graphics </title> </head> <script> counter =0; function wopen(url, name, w, h){ // This function was taken on www.boutell.com w += 32; h += 96; counter +=1; var win = window.open(url, counter, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no'); win.resizeTo(w, h); win.focus(); } </script> <script> function showSourceHelpPage(){ var sourceHelpPage = dhtmlwindow.open("sourceHelpPage", "iframe", "helpPages/source_%s.html", "Definition of 'source'", "width=875px,height=100px,resize=1,scrolling=1,center=1", "recal") sourceHelpPage.moveTo("middle", "middle"); }""" %(self.displayedLanguage) + """ function showClientHelpPage(){ var clientHelpPage = dhtmlwindow.open("client", "iframe", "helpPages/client_%s.html", "Definition of 'client'", "width=875px,height=150px,resize=1,scrolling=1,center=1", "recal") .moveTo("middle", "middle"); }""" %(self.displayedLanguage) + """ </script> <STYLE> <!-- A{text-decoration:none} --> </STYLE> <style type="text/css"> div.left { float: left; } div.right {float: right; } </style> <style type="text/css"> div.tableContainer { width: 95%; /* table width will be 99% of this*/ height: 275px; /* must be greater than tbody*/ overflow: auto; margin: 0 auto; } table { width: 99%; /*100% of container produces horiz. scroll in Mozilla*/ border: none; background-color: #f7f7f7; table-layout: fixed; } table>tbody { /* child selector syntax which IE6 and older do not support*/ overflow: auto; height: 225px; overflow-x: hidden; } thead tr { position:relative; } thead td, thead th { text-align: center; font-size: 14px; background-color:"#006699"; color: steelblue; font-weight: bold; border-top: solid 1px #d8d8d8; } td { color: #000; padding-right: 2px; font-size: 12px; text-align: left; border-bottom: solid 1px #d8d8d8; border-left: solid 1px #d8d8d8; } tfoot td { text-align: center; font-size: 11px; font-weight: bold; background-color: papayawhip; color: steelblue; border-top: solid 2px slategray; } td:last-child {padding-right: 20px;} /*prevent Mozilla scrollbar from hiding cell content*/ </style> <body text="#000000" link="#FFFFFF" vlink="000000" bgcolor="#FFF4E5" > <h2>""" + _( "Daily graphics for RX sources from MetPx.") + """ <font size = "2">""" + _("*updated hourly") + """</font></h2> <div class="tableContainer"> <table> <thead> <tr> <td bgcolor="#006699"> <div class = "rxTableEntry"> <font color = "white"> <center> Sources <br> <a target ="popup" href="#" onClick="showSourceHelpPage(); return false;"> ? </a> </center> </font> </div> </td> <td bgcolor="#006699"> <font color = "white">""" + _("List of available daily graphics.") + """</font> </td> </tr> </thead> <tbody> """) for rxName in rxNamesArray : if rxNames[rxName] == "" : fileHandle.write( """<tr> <td bgcolor="#99FF99"> %s</td> """ %(rxName)) fileHandle.write( """<td bgcolor="#66CCFF"> """ + _("Days") + """ : """ ) else: machineName = self.getMachineNameFromDescription( rxNames[rxName] ) fileHandle.write( """<tr> <td bgcolor="#99FF99"><div class="left"> %s</div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ %(rxName, rxNames[rxName].replace("'","").replace('"','').replace( ",", ", "), machineName ) ) fileHandle.write( """<td bgcolor="#66CCFF"> """ + _("Days") + """ : """ ) for day in self.days: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( day ) _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.filesLanguage) file = file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("daily/rx/%s/")%( rxName ) + str(currentYear) + "/" + str(currentMonth) + "/" + str(currentDay) + ".png" webLink = _("archives/daily/rx/%s/")%( rxName ) + str(currentYear) + "/" + str(currentMonth) + "/" + str(currentDay) + ".png" _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="%s" href="%s">"""%( rxName, webLink) + "%s" %StatsDateLib.getDayOfTheWeek(day) + """ </a>""" ) else : pass fileHandle.write( """</td></tr>""" ) fileHandle.write( """ </tbody> </table> </div> <h2>""" + _("Daily graphics for TX clients from MetPx.") + """ <font size = "2">""" +_("*updated hourly") + """</font></h2> <div class="tableContainer"> <table> <thead> <tr> <td bgcolor="#006699"> <div class = "txTableEntry"> <font color = "white"> <center> Clients <br> <a target ="popup" href="#" onClick="showClientHelpPage(); return false;"> ? </a> <center> </font> </div> </td> <td bgcolor="#006699"> <div class = "txTableEntry"> <font color = "white">""" + _("List of available daily graphics.") + """</font> </div> </td> </tr> </thead> <tbody> """ ) for txName in txNamesArray : if txNames[txName] == "" : fileHandle.write( """<tr> <td bgcolor="#99FF99"> %s</td> """ %(txName)) fileHandle.write( """<td bgcolor="#66CCFF"><div class = "txTableEntry"> """ + _("Days") + """ : """ ) else: machineName = self.getMachineNameFromDescription( txNames[txName] ) fileHandle.write( """<tr> <td bgcolor="#99FF99"><div class="left"> %s </div><div class="right"><a href="#" onClick="descriptionWindow.load('inline', '%s', 'Description');descriptionWindow.show(); return false"><font color="black">?</font></a></div><br>(%s)</td> """ %(txName, txNames[txName].replace("'","").replace('"','').replace(",", ", "), machineName )) fileHandle.write( """<td bgcolor="#66CCFF"> """ + _("Days") + """ : """ ) for day in self.days: currentYear, currentMonth, currentDay = StatsDateLib.getYearMonthDayInStrfTime( day ) _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.filesLanguage ) file = self.pathsTowardsGraphics.STATSGRAPHSARCHIVES + _("/daily/tx/%s/")%( txName ) + str(currentYear) + "/" + str(currentMonth) + "/" + str(currentDay) + ".png" webLink = _("archives/daily/tx/%s/")%( txName ) + str(currentYear) + "/" + str(currentMonth) + "/" + str(currentDay) + ".png" _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.displayedLanguage ) if os.path.isfile( file ): fileHandle.write( """<a target ="%s" href="%s">"""%( rxName, webLink) + "%s" %StatsDateLib.getDayOfTheWeek(day) +""" </a>""" ) else : pass fileHandle.write( "</td></tr>" ) fileHandle.write( """ </tbody> </table> </body> </html> """ ) fileHandle.close()
def printWebPage( self, machineTags, machineParameters ): """ Generates a web page based on all the rxnames and tx names that have run during the pas x days. Only links to available graphics will be displayed. """ global _ rxTypes = [ _("bytecount"), _("filecount"), _("errors")] txTypes = [ _("latency"), _("filesOverMaxLatency"), _("bytecount"), _("filecount"), _("errors") ] timeTypes = [ _("daily"),_("weekly"),_("monthly"),_("yearly")] updateFrequency= { _("daily"): _("(upd. hourly)"),_("weekly"):_("(upd. hourly)"), _("monthly"):_("(upd. weekly)"),_("yearly"):_("(upd. monthly)")} for machineTag in machineTags: machineNames = machineParameters.getPairedMachinesAssociatedWithListOfTags( [ machineTag ] ) for machineName in machineNames: if not os.path.isdir(self.pathsTowardsGraphics.STATSWEBPAGESHTML): os.makedirs( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML ) machineName = TotalsGraphicsWebPageGenerator.getCombinedMachineName( machineName ) file = "%s%s_%s.html" %( self.pathsTowardsOutputFiles.STATSWEBPAGESHTML, machineTag, self.displayedLanguage ) fileHandle = open( file , 'w' ) fileHandle.write( """ <html> <head> <title> PX Graphics </title> </head> <script> counter =0; function wopen(url, name, w, h){ // This function was taken on www.boutell.com w += 32; h += 96; counter +=1; var win = window.open(url, counter, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no'); win.resizeTo(w, h); win.focus(); } </script> <STYLE> </STYLE> <style type="text/css"> div.left { float: left; } div.right {float: right; } <!-- A{text-decoration:none} --> <!-- td { white-space: pre-wrap; /* css-3 */ } // --> </style> <body text="#000000" link="#FFFFFF" vlink="000000" bgcolor="#FFF4E5" > <h2>""" + _("RX totals for") + ' %s'%string.upper( machineTag ) + """</h2> <table style="table-layout: fixed; width: 100%; border-left: 0px gray solid; border-bottom: 0px gray solid; padding:0px; margin: 0px" cellspacing=10 cellpadding=6 > <tr> <td bgcolor="#006699" ><font color = "white"><div class="left">Type</font></td> <td bgcolor="#006699" title =" """ + _( "Display the total of bytes received by all sources.") + """ "><font color = "white"><div class="left">""" + _("ByteCount") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/byteCount_%s.html' """%(self.displayedLanguage)+ """ , 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ +_( "Display the total of files received by all sources.") + """ "><font color = "white"><div class="left">""" + _("FileCount") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/fileCount_%s.html' """%(self.displayedLanguage)+ """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ +_( "Display the total of errors that occured during all the receptions.") + """ "><font color = "white"><div class="left">""" + _("Errors") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/errors_%s.html' """%(self.displayedLanguage)+ """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> </tr> """ ) for timeType in timeTypes: fileHandle.write( """ <tr> <td bgcolor="#99FF99" > %s %s</td> """ %(( timeType[0].upper() + timeType[1:] ), updateFrequency[timeType] ) ) if timeType == timeTypes[0] : timeContainer = self.days elif timeType == timeTypes[1] : timeContainer = self.weeks elif timeType == timeTypes[2] : timeContainer = self.months elif timeType == timeTypes[3] : timeContainer = self.years for type in rxTypes: fileHandle.write( """<td bgcolor="#66CCFF"> """ ) for x in timeContainer: year, month, day = StatsDateLib.getYearMonthDayInStrfTime( x ) week = time.strftime( "%W", time.gmtime(x)) if timeType == timeTypes[0] : file = _("%sdaily/totals/%s/rx/%s/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, month, type, day ) webLink = _("archives/daily/totals/%s/rx/%s/%s/%s/%s.png") %( machineName, year, month, type, day ) elif timeType == timeTypes[1]: file = _("%sweekly/totals/%s/rx/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, type, week ) webLink = _("archives/weekly/totals/%s/rx/%s/%s/%s.png") %( machineName, year, type, week ) elif timeType == timeTypes[2]: file = _("%smonthly/totals/%s/rx/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, type, month ) webLink = _("archives/monthly/totals/%s/rx/%s/%s/%s.png") %( machineName, year, type, month ) elif timeType == timeTypes[3]: file = _("%syearly/totals/%s/rx/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, type, year ) webLink = _("archives/yearly/totals/%s/rx/%s/%s.png") %( machineName, type, year ) if os.path.isfile(file): if timeType == timeTypes[0] : label = time.strftime( "%a", time.gmtime(x)) elif timeType == timeTypes[1]: label = week elif timeType == timeTypes[2]: label = month elif timeType == timeTypes[3]: label = year fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">"""%( label, webLink ) + "%s" %label + """ </a>""" ) fileHandle.write( """</td>""" ) fileHandle.write( """</tr>""" ) fileHandle.write( """</table>""" ) ####################################txPart fileHandle.write(""" <h2>""" + _("TX totals for") + " %s " %( string.upper( machineTag ) + """</h2> <table style="table-layout: fixed; width: 100%; border-left: 0px gray solid; border-bottom: 0px gray solid; padding:0px; margin: 0px" cellspacing=10 cellpadding=6 > <tr> <td bgcolor="#006699" title = ><font color = "white">Type</font></td> <td bgcolor="#006699" """ + _("Display the average latency of file transfers for all clients.") + """ "><font color = "white"><font color = "white"><div class="left">""" + _("Latency")+"""</div><a target ="popup" href="help" onClick="wopen('helpPages/latency_%s.html'"""%self.displayedLanguage + """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ + _( "Display the number of files for wich the latency was over 15 seconds for all clients.") +""" "><font color = "white"><div class="left">""" + _("Files Over Max. Lat.") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/filesOverMaxLatency_%s.html'"""%self.displayedLanguage + """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ + _( "Display number of bytes transfered to all clients.") + """ "><font color = "white"><div class="left">""" +_("ByteCount") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/byteCount_%s.html'"""%self.displayedLanguage + """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ + _( "Display the number of files transferred every day to all clients.") + """ "><font color = "white"><div class="left">""" + _("FileCount") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/fileCount_%s.html'""" %self.displayedLanguage + """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> <td bgcolor="#006699" title =" """ + _( "Display the total of errors that occured during the file transfers to allclients.") + """ "><font color = "white"><div class="left">""" + _("Errors") + """</div><a target ="popup" href="help" onClick="wopen('helpPages/errors_%s.html'"""%self.displayedLanguage + """, 'popup', 875, 100); return false;"><div class="right">?</div></a></font></td> </tr> """ ) ) for timeType in timeTypes: fileHandle.write( """ <tr> <td bgcolor="#99FF99" ><div style="width:10pt";>%s %s</div> </td> """ %(( timeType[0].upper() + timeType[1:] ), updateFrequency[timeType] ) ) if timeType == timeTypes[0] : timeContainer = self.days elif timeType == timeTypes[1]: timeContainer = self.weeks elif timeType == timeTypes[2]: timeContainer = self.months elif timeType == timeTypes[3]: timeContainer = self.years for type in txTypes: fileHandle.write( """<td bgcolor="#66CCFF"> """) for x in timeContainer: year, month, day = StatsDateLib.getYearMonthDayInStrfTime( x ) week = time.strftime( "%W", time.gmtime(x)) if timeType == timeTypes[0] : file = _("%sdaily/totals/%s/tx/%s/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, month, type, day ) webLink = _("archives/daily/totals/%s/tx/%s/%s/%s/%s.png") %( machineName, year, month, type, day ) elif timeType == timeTypes[1]: file = _("%sweekly/totals/%s/tx/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, type, week ) webLink = _("archives/weekly/totals/%s/tx/%s/%s/%s.png") %( machineName, year, type, week ) elif timeType == timeTypes[2]: file = _("%smonthly/totals/%s/tx/%s/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, year, type, month ) webLink = _("archives/monthly/totals/%s/tx/%s/%s/%s.png") %( machineName, year, type, month ) elif timeType == timeTypes[3]: file = _("%syearly/totals/%s/tx/%s/%s.png") %( self.pathsTowardsGraphics.STATSGRAPHSARCHIVES, machineName, type, year ) webLink = _("archives/yearly/totals/%s/tx/%s/%s.png") %( machineName, type, year ) print file if os.path.isfile(file): if timeType == timeTypes[0] : label = time.strftime( "%a", time.gmtime(x)) elif timeType == timeTypes[1]: label = week elif timeType == timeTypes[2]: label = month elif timeType == timeTypes[3]: label = year fileHandle.write( """<a target ="popup" href="%s" onClick="wopen('%s', 'popup', 875, 240); return false;">"""%( label, webLink ) + "%s" %str(label) + """ </a>""" ) fileHandle.write( """</td>""" ) fileHandle.write( """</tr>""" ) fileHandle.write( """</table>""") fileHandle.write( """</body></html>""") #End of tx part. fileHandle.close()