예제 #1
0
    def prepareQuery(self):
        """
            @summary : Buildup the query  to be executed.
        
            @SIDE_EFFECT :  modifies self.query value.
            
        """
        
        global _ 
        
        if self.queryParameters.combine == 'true':
            totals = True
            mergerType = "regular"
        else:
            totals = False      
            mergerType = ""
            
            
        fixedCurrent  = False
        fixedPrevious = False
        
        if _("current")  in str(self.queryParameters.fixedSpan).lower() :
            fixedCurrent = True 
        elif _("previous") in str(self.queryParameters.fixedSpan).lower():
            fixedPrevious = True      
        else:
            fixedCurrent  = False
            fixedPrevious = False 
       

            
        hour      = self.queryParameters.endTime.split(" ")[1]
        splitDate = self.queryParameters.endTime.split(" ")[0].split( '-' )
        
        date =  splitDate[2] + '-' + splitDate[1]  + '-' + splitDate[0]  + " " + hour 
        if self.queryParameters.span == "": 
            timespan = 0 
        else:
            timespan = int(self.queryParameters.span )    
            
        StatsDateLib.setLanguage( self.querierLanguage )
        startTime, endTime = StatsDateLib.getStartEndInIsoFormat(date, timespan, self.queryParameters.specificSpan, fixedCurrent, fixedPrevious )
        
        timespan = int( StatsDateLib.getSecondsSinceEpoch( endTime ) - StatsDateLib.getSecondsSinceEpoch( startTime ) ) / 3600   
        
        combinedMachineName = ""
        for machine in self.queryParameters.machines:
            combinedMachineName = combinedMachineName + machine

        machines = [ combinedMachineName ]
       
        
        self.graphicProducer = RRDGraphicProducer( self.queryParameters.fileTypes[0], self.queryParameters.statsTypes ,\
                                                   totals,  self.queryParameters.specificSpan,\
                                                   self.queryParameters.sourLients, timespan,\
                                                   startTime, endTime, machines, False,
                                                   mergerType, True, self.querierLanguage, self.querierLanguage )
  
        StatsDateLib.setLanguage( LanguageTools.getMainApplicationLanguage() )
예제 #2
0
    def __init__( self, displayedLanguage = 'en', filesLanguage='en', days = None, \
                  weeks = None, months = None, years = None, \
                  pathsTowardsGraphics = None, pathsTowardsOutputFiles = None  ):
        """
        
            @summary : Constructor 
            
            @param displayedLanguage: Languages in which to display 
                                      the different captions found within 
                                      the generated web page.  
            
            @param fileLanguages: Language in which the files that 
                                  will be referenced within this page
                                  have been generated.
                                  
            @param days : List of days that the web page covers.
        
            @note : Will set two global translators to be used throughout this module 
                    _ which translates every caption that is to be printed.
                    _F which translates every filename that is to be linked.     
        """
        
        configParameters = StatsConfigParameters()
        configParameters.getGeneralParametersFromStatsConfigurationFile()
      
        global _ 
        _ =  self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, displayedLanguage )
        
        if days == None:
            self.setDays()
        else:    
            self.days = days 
            
        if weeks == None:
            self.setWeeks()
        else:    
            self.weeks = weeks             
            
        if months == None:
            self.setMonths()
        else:    
            self.months = months 
                            
        if years == None:
            self.setYears()
        else:    
            self.years = years                 
                
        self.displayedLanguage = displayedLanguage
        self.filesLanguage     = filesLanguage
       
        self.pathsTowardsGraphics = StatsPaths()
        self.pathsTowardsGraphics.setPaths( filesLanguage )
        
        self.pathsTowardsOutputFiles = StatsPaths()
        self.pathsTowardsOutputFiles.setPaths( self.displayedLanguage )

        StatsDateLib.setLanguage(filesLanguage)
예제 #3
0
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
예제 #4
0
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 
예제 #5
0
    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()
예제 #6
0
 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()                 
예제 #8
0
    def prepareQuery(self):
        """
            @summary : Buildup the query  to be executed.
        
            @SIDE_EFFECT :  modifies self.query value.
            
        """

        global _

        if self.queryParameters.combine == 'true':
            totals = True
            mergerType = "regular"
        else:
            totals = False
            mergerType = ""

        fixedCurrent = False
        fixedPrevious = False

        if _("current") in str(self.queryParameters.fixedSpan).lower():
            fixedCurrent = True
        elif _("previous") in str(self.queryParameters.fixedSpan).lower():
            fixedPrevious = True
        else:
            fixedCurrent = False
            fixedPrevious = False

        hour = self.queryParameters.endTime.split(" ")[1]
        splitDate = self.queryParameters.endTime.split(" ")[0].split('-')

        date = splitDate[2] + '-' + splitDate[1] + '-' + splitDate[
            0] + " " + hour
        if self.queryParameters.span == "":
            timespan = 0
        else:
            timespan = int(self.queryParameters.span)

        StatsDateLib.setLanguage(self.querierLanguage)
        startTime, endTime = StatsDateLib.getStartEndInIsoFormat(
            date, timespan, self.queryParameters.specificSpan, fixedCurrent,
            fixedPrevious)

        timespan = int(
            StatsDateLib.getSecondsSinceEpoch(endTime) -
            StatsDateLib.getSecondsSinceEpoch(startTime)) / 3600

        combinedMachineName = ""
        for machine in self.queryParameters.machines:
            combinedMachineName = combinedMachineName + machine

        machines = [combinedMachineName]


        self.graphicProducer = RRDGraphicProducer( self.queryParameters.fileTypes[0], self.queryParameters.statsTypes ,\
                                                   totals,  self.queryParameters.specificSpan,\
                                                   self.queryParameters.sourLients, timespan,\
                                                   startTime, endTime, machines, False,
                                                   mergerType, True, self.querierLanguage, self.querierLanguage )

        StatsDateLib.setLanguage(LanguageTools.getMainApplicationLanguage())