Esempio n. 1
0
    def buildThisHoursFileName(client="someclient",
                               offset=0,
                               currentTime="",
                               fileType="tx",
                               machine="someMachineName"):
        """ 
            @summary : Builds a filename using current currentTime.
            
            @Note : The format will be something like this :
                    StatsPaths.STATSPICKLES/clientName/date/TXorRX//machine_hour
                    Ex : StatsPaths.STATSPICKLES/clientName/20060707/tx/machinex_12:00:00
            
                    offset can be used to find a file from an hour close to the current one 
            
                    tempcurrentTime can also be used to build a filename from another hour. 
            
            
            @warning :To be used only with pickles created hourly.
                
        """

        timeFolder = ""

        if currentTime == "":
            currentTime = time.time()
        else:
            currentTime = StatsDateLib.getSecondsSinceEpoch(currentTime)

        currentTime = currentTime + (offset * StatsDateLib.HOUR)
        splitTime = time.gmtime(currentTime)

        for i in range(3):

            if int(splitTime[i]) < 10:
                timeFolder = timeFolder + "0" + str(splitTime[i])
            else:
                timeFolder = timeFolder + str(splitTime[i])

        hour = StatsDateLib.getHoursFromIso(
            StatsDateLib.getIsoFromEpoch(currentTime))

        maxLt = (os.statvfs(STATSPATHS.STATSPICKLES)[statvfs.F_NAMEMAX])

        fileName = ("%s" + "%." + str(maxLt) + "s/%s/%s/%." + str(maxLt) +
                    "s_%s") % (STATSPATHS.STATSPICKLES, client, timeFolder,
                               fileType, str(machine), str(hour))

        return fileName
Esempio n. 2
0
 def buildThisHoursFileName(  client = "someclient", offset = 0, currentTime = "", fileType = "tx", machine = "someMachineName" ):
     """ 
         @summary : Builds a filename using current currentTime.
         
         @Note : The format will be something like this :
                 StatsPaths.STATSPICKLES/clientName/date/TXorRX//machine_hour
                 Ex : StatsPaths.STATSPICKLES/clientName/20060707/tx/machinex_12:00:00
         
                 offset can be used to find a file from an hour close to the current one 
         
                 tempcurrentTime can also be used to build a filename from another hour. 
         
         
         @warning :To be used only with pickles created hourly.
             
     """    
     
     timeFolder = ""
            
     if currentTime == "":
         currentTime = time.time()
     else:
         currentTime = StatsDateLib.getSecondsSinceEpoch( currentTime )    
     
     currentTime = currentTime + ( offset * StatsDateLib.HOUR )
     splitTime = time.gmtime( currentTime )    
             
     for i in range( 3 ):
         
         if int( splitTime[i] ) < 10 :
             timeFolder = timeFolder + "0" + str( splitTime[i] )
         else:
             timeFolder = timeFolder + str( splitTime[i] )          
     
             
     hour = StatsDateLib.getHoursFromIso( StatsDateLib.getIsoFromEpoch( currentTime ) )
     
     maxLt = ( os.statvfs( STATSPATHS.STATSPICKLES )[statvfs.F_NAMEMAX])
     
     fileName = ( "%s" + "%." +  str( maxLt ) + "s/%s/%s/%." + str( maxLt ) + "s_%s" )   %( STATSPATHS.STATSPICKLES, client, timeFolder,  fileType, str(machine),  str(hour) )  
             
     return fileName 
Esempio n. 3
0
    def getXTics( self ):
        """
           
           @summary : This method builds all the xtics used to seperate data on the x axis.
            
                      Xtics values will are used in the plot method so they will be drawn on 
                      the graphic. 
           
           @note:     All xtics will be devided hourly. This means a new xtic everytime 
                      another hour has passed since the starting point.  
            
            
        """
        
        _ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.workingLanguage )
        #print "get x tics"
        if self.logger != None :
            self.logger.debug( _("Call to getXtics received") )
        
        nbBuckets = ( len( self.stats[0].statsCollection.timeSeperators ) )
        xtics = ''
        startTime = StatsDateLib.getSecondsSinceEpoch( self.stats[0].statsCollection.timeSeperators[0] )
        
        if nbBuckets != 0 :
            
            for i in range(0, nbBuckets ):
                 
                   
                if ( (  StatsDateLib.getSecondsSinceEpoch(self.stats[0].statsCollection.timeSeperators[i]) - ( startTime  ) ) %(60*60)  == 0.0 ): 
                    
                    hour = StatsDateLib.getHoursFromIso( self.stats[0].statsCollection.timeSeperators[i] )
                    
                    xtics += '"%s" %i, '%(  hour , StatsDateLib.getSecondsSinceEpoch(self.stats[0].statsCollection.timeSeperators[i] ) )

        
        #print nbBuckets
        #print "len xtics %s" %len(xtics) 
        return xtics[:-2]