• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python StatsDateLib.StatsDateLib类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pxStats.lib.StatsDateLib.StatsDateLib的典型用法代码示例。如果您正苦于以下问题:Python StatsDateLib类的具体用法?Python StatsDateLib怎么用?Python StatsDateLib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getStartEndOfWebPage

 def getStartEndOfWebPage():
     """
         @summary : Returns the time of the first 
                    graphics to be shown on the web 
                    page and the time of the last 
                    graphic to be displayed. 
         
         @return :  start, end tuple in iso format.
         
     """
     
     currentTime = StatsDateLib.getIsoFromEpoch( time.time() )  
     
     currentDate = datetime.date( int(currentTime[0:4]), int(currentTime[5:7]), 1 )     
           
         
     nbMonthsToRevwind = NB_MONTHS_DISPLAYED - 1 
         
     if currentDate.month - (nbMonthsToRevwind%12) < 1 :            
         month = currentDate.month - (nbMonthsToRevwind%12)+12 
     
     if  currentDate.month -nbMonthsToRevwind < 1:
         year  = currentDate.year - int( abs(math.floor( float( ( currentDate.month - nbMonthsToRevwind  ) / 12 ) ) ) ) 
     
     else :                 
         month = currentDate.month - nbMonthsToRevwind             
         year = currentDate.year
         
         
     start  = "%s-%s-%s 00:00:00" %( year,month,"01" )      
     end   = StatsDateLib.getIsoTodaysMidnight( currentTime )
     
         
     return start, end 
开发者ID:hawkeye438,项目名称:metpx,代码行数:34,代码来源:MonthlyGraphicsWebPageGenerator.py


示例2: main

def main():
    """
        @summary : This program is to be used to backup 
                   rrd databases and their corresponding
                   time of update files. Backing up rrd 
                   databases at various point in time is a
                   recommended paractice in case newly
                   entered data is not valid. 
        
    """
    
    setGlobalLanguageParameters()
    
    currentTime = time.time()        
    currentTime = StatsDateLib.getIsoFromEpoch( currentTime )
    currentTime = StatsDateLib.getIsoWithRoundedSeconds( currentTime )
    currentTime = currentTime.replace(" ", "_")
    
    backupsToKeep = 20
    
    if len( sys.argv ) == 2:
        try:
            backupsToKeep =  int( sys.argv[1] )
        except:
            print _( "Days to keep value must be an integer. For default 20 backups value, type nothing." )
            sys.exit()
                      
    backupDatabaseUpdateTimes( currentTime, backupsToKeep )
    backupDatabases( currentTime, backupsToKeep )
开发者ID:hawkeye438,项目名称:metpx,代码行数:29,代码来源:backupRRDDatabases.py


示例3: setMonths

 def setMonths( self ):
     """
         @Summary : Sets the months value to an array containing
                    the last X months in "since epoch" numbers
                    based on the globally set NB_MONTHS_DISPLAYED
                   value.
     
     """
     
     currentTime = time.time()
     currentTime = StatsDateLib.getIsoFromEpoch( currentTime )
     currentDate = datetime.date( int(currentTime[0:4]), int(currentTime[5:7]), 1 )  # day always  = 1 in case currentDate.day > 28 
        
     months = []   
         
     for i in range(0,NB_MONTHS_DISPLAYED):
         
         if currentDate.month - (i%12) < 1 :            
             month = currentDate.month - (i%12)+12 
         
         if  currentDate.month -i < 1:
             year  = currentDate.year - int( abs(math.floor( float( ( currentDate.month - i  ) / 12 ) ) ) ) 
         
         else :                 
             month = currentDate.month - i             
             year = currentDate.year                      
          
         months.append( StatsDateLib.getSecondsSinceEpoch( "%s-%s-%s 00:00:00" %(year,month,"01") ) )
             
     months.reverse()
         
     self.months =  months
     print months
开发者ID:hawkeye438,项目名称:metpx,代码行数:33,代码来源:MonthlyGraphicsWebPageGenerator.py


示例4: getThreeClosestDatabasesBackups

def getThreeClosestDatabasesBackups( infos ):
    """
        @summary : Returns the three databases backups
                  that are the closest to the startTime 
                  asked for the database recollection.
                  
        @param infos :
        
        @return: the three databases backups
                 that are the closest to the startTime 
                 asked for the database recollection.          
    """
    
    closestFiles = []
    differenceFileTuples = []
    files = os.listdir( StatsPaths.STATSDB + 'databasesTimeOfUpdatesBackups/' )
    
    startTimeInEpochformat = StatsDateLib.getSecondsSinceEpoch( infos.databasesRecollectionStartTime )
    
    for file in files:
        #try:
        
        fileDateInIsoFormat = "%s %s" %(str(file).split("_")[0], str(file).split("_")[1] ) 
        
        tupleToAdd = ( abs( StatsDateLib.getSecondsSinceEpoch(fileDateInIsoFormat) - startTimeInEpochformat ), file )
        
        differenceFileTuples.append( tupleToAdd )     
        

    
    for tuple in differenceFileTuples [:3] :
        closestFiles.append( tuple[1] )
        
    return closestFiles
开发者ID:hawkeye438,项目名称:metpx,代码行数:34,代码来源:recollectData.py


示例5: getStartAndEndTimeForPickleRecollection

def getStartAndEndTimeForPickleRecollection():
    """
        @summary : Gets the start time and the endTime 
                   of the pickle recollection from the
                   user's input.
        
        @return : Returns the startTime and endTime.
        
    """
    
    startTime = raw_input( "Enter the startTime of the pickle recollection ( yyyy-mm-dd hh:mm:ss) : ")
    
    while not StatsDateLib.isValidIsoDate( startTime ):
        print "Error. The entered date must be of the iso format."
        startTime = raw_input( "Enter the startTime of the pickle recollection ( yyyy-mm-dd hh:mm:ss) : ")
    
    endTime= raw_input( "Enter the endTime of the pickle recollection ( yyyy-mm-dd hh:mm:ss or 'now' for current time ) : ")    
    
    while( str(endTime).lower() != "now" and not StatsDateLib.isValidIsoDate( endTime ) and ( StatsDateLib.isValidIsoDate( endTime ) and endTime<= startTime ) ) :
        if  StatsDateLib.isValidIsoDate( endTime ) and endTime<= startTime :
            print "Error. End time must be after startTime( %s ). "
        elif StatsDateLib.isValidIsoDate( endTime ):
             print "Error. The entered date must be of the iso format."
        
        endTime= raw_input( "Enter the endTime of the pickle recollection ( yyyy-mm-dd hh:mm:ss or 'now' for current time ) : ") 
            
    if endTime == "now" :
        endTime = StatsDateLib.getIsoFromEpoch( time.time() )

                
    return startTime, endTime
开发者ID:hawkeye438,项目名称:metpx,代码行数:31,代码来源:recollectData.py


示例6: getTimeOfLastUpdateInLogs

 def getTimeOfLastUpdateInLogs(self):
     """
         
         @summary : Returns the time of the last update in iso format.
    
         @return : None if no update as found, EPCH is returned in iso format,
                   as to make sure an update is made since no prior updates exist.
         
     """
     
     timeOfLastUpdate = StatsDateLib.getIsoTodaysMidnight( StatsDateLib.getCurrentTimeInIsoformat() ) 
     
     paths = StatsPaths()
     paths.setPaths()
     
     updatesDirectory = paths.STATSTEMPAUTUPDTLOGS + self.updateType + "/"
     
     if not os.path.isdir( updatesDirectory ):
         os.makedirs(updatesDirectory)       
     allEntries = os.listdir(updatesDirectory) 
     
     if allEntries !=[] :
         allEntries.sort()
         allEntries.reverse() 
         timeOfLastUpdate = os.path.basename( allEntries[0] ).replace( "_"," " )
         
         
     return timeOfLastUpdate
开发者ID:hawkeye438,项目名称:metpx,代码行数:28,代码来源:AutomaticUpdatesManager.py


示例7: setMonths

 def setMonths( self ):
     """
         Returns the 3 months including current month.
     
     """
     
     currentTime = time.time()
     currentTime = StatsDateLib.getIsoFromEpoch( currentTime )
     currentDate = datetime.date( int(currentTime[0:4]), int(currentTime[5:7]), 1 )     
        
     months = []
     
        
     for i in range(0,5):
         
         if currentDate.month -i < 1 :
             month = currentDate.month -i + 12
             year  = currentDate.year -i 
         else :     
             month = currentDate.month -i 
             year = currentDate.year
             
        
         newdate = StatsDateLib.getSecondsSinceEpoch( "%s-%s-01 00:00:00" %( year,month ) ) 
         months.append( newdate )
         #print year,month,day
     
     months.reverse()
         
     self.months = months
开发者ID:hawkeye438,项目名称:metpx,代码行数:30,代码来源:TotalsGraphicsWebPagesGenerator.py


示例8: __init__

    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)
开发者ID:hawkeye438,项目名称:metpx,代码行数:58,代码来源:TotalsGraphicsWebPagesGenerator.py


示例9: mergePicklesFromDifferentHours

 def mergePicklesFromDifferentHours( logger = None , startTime = "2006-07-31 13:00:00",\
                                     endTime = "2006-07-31 19:00:00", client = "satnet",\
                                     machine = "pdsPM", fileType = "tx" ):
     """
         @summary : This method merges entire hourly pickles files together. 
         
         @None    : This does not support merging part of the data of pickles.   
     
     """
     
     if logger != None :
         logger.debug( _("Call to mergeHourlyPickles received.") )
         logging = True
     else:
         logging = False
             
     pickles = []
     entries = {}
     width = StatsDateLib.getSecondsSinceEpoch( endTime ) - StatsDateLib.getSecondsSinceEpoch( startTime )
     startTime = StatsDateLib.getIsoWithRoundedHours( startTime )
     
     seperators = [startTime]
     seperators.extend( StatsDateLib.getSeparatorsWithStartTime( startTime = startTime , width=width, interval=60*StatsDateLib.MINUTE )[:-1])
         
     for seperator in seperators :
         pickles.append( StatsPickler.buildThisHoursFileName(  client = client, offset = 0, currentTime = seperator, machine = machine, fileType = fileType ) )        
     
     
     startingNumberOfEntries = 0
     #print "prior to loading and merging pickles : %s " %( StatsDateLib.getIsoFromEpoch( time.time() ) ) 
     for pickle in pickles : 
         
         if os.path.isfile( pickle ) :
             
                 
             tempCollection = CpickleWrapper.load( pickle )
             if tempCollection != None :
                 for i in xrange( len( tempCollection.fileEntries )  ):
                     entries[startingNumberOfEntries + i] = tempCollection.fileEntries[i]
                 startingNumberOfEntries = startingNumberOfEntries + len( tempCollection.fileEntries ) 
             else:                    
                 sys.exit()
         else:
                        
             emptyEntries =  PickleMerging.fillWithEmptyEntries( nbEmptyEntries = 60, entries = {} )
             for i in xrange( 60 ):
                 entries[i + startingNumberOfEntries ] = emptyEntries [i]
             startingNumberOfEntries = startingNumberOfEntries + 60
     
     #print "after the  loading and merging og pickles : %s " %( StatsDateLib.getIsoFromEpoch( time.time() ) )        
     
     statsCollection = FileStatsCollector(  startTime = startTime , endTime = endTime, interval = StatsDateLib.MINUTE, totalWidth = width, fileEntries = entries,fileType= fileType, logger = logger, logging = logging )
        
             
     return statsCollection        
开发者ID:hawkeye438,项目名称:metpx,代码行数:55,代码来源:PickleMerging.py


示例10: askUserAboutUpdatingLogs

def askUserAboutUpdatingLogs( infos ):
    """
        @Summary : Asks user about whether or not
                   he wants to update the log files
                   on his machine.
        
        @returns True or False              
    """
    
    updateLofFiles = False
    os.system( "clear" )
    showPresentation()
    print ""
    print ""
    print "***************** Important note *****************" 
    print "Collection or recollection of pickle files "
    print "is closely linked to the log files found on this machine."
    
    if StatsDateLib.getIsoWithRoundedHours( infos.picklesRecollectionStartTime ) != StatsDateLib.getIsoWithRoundedHours( StatsDateLib.getIsoFromEpoch( time.time() )) : 
        print "Data recollection is set to take place up to the current hour."
        print "For the end of the recollection it is recommended that log file be updated."
        print "However, if the recollection spans over a long while and that the log file currently "
        print "on this machine are 'old' and cover the start of the recollection,"
        print "updating log files might cause you to loose some or all of those old files."
        
    else :
        print "Data recollection is set to end PRIOR to the current hour."
        print "In this case, log file updates are usually useless."
        print "In the case where the span between the start of the recollection "
        print "is longer than the span covered by the currently accessible log files, "
        print "usefull log files will be lsot by updating them."
        print "However the opposite could also be true. If problems occured and "
        print "databases are seriously outdated, updating them will be the only solution "
        print "capable of making some or all the needed log file data accessible for pickling."
    
    
    print ""
    print "***Please review log files prior to specifying whether or not you want to update them or not.***"
    print ""
    input = raw_input( "Do you want to update log files ? ( y or n ) : " )
       
    while ( str( input ).lower() != 'n' and   str( input ).lower() != 'y' ):
        print "Please enter one of the following choices : y/Y or n/N."
        input = raw_input( "Do you want to update log files ? ( y or n ) : " )
   
    if str( input ).lower() == 'y' :
        print "Log files will be updated."
        updateLofFiles =  True
    else:
        print "Log files will not be updated."
    
    
    
    return updateLofFiles
开发者ID:hawkeye438,项目名称:metpx,代码行数:54,代码来源:recollectData.py


示例11: getSeperatorsForHourlyTreatments

 def getSeperatorsForHourlyTreatments( startTime, endTime, currentFreeMemory, fileSizesPerHour, usage= "rrd"  ):    
     """
     
         @summary : returns a list of time seperators based on a list of file and 
                    the current amount of free memory. Each seperator represents the time 
                    associated with a certain hourly file. Each seperator will represent
                    the maximum amount of files that can be treated at the same time 
                    without busting the current memory. 
         
         @attention: List fo files MUST refer to hourly files. 
         
         @param startTime: Startime in iso format of the interval to work with.
         @param endTime: End time in iso format of the interval to work with.
         @param currentFreeMemory: Maximum amout of memory to use per seperation.
         @param fileSizesPerHour: size of the file(s) to be treated at every hour.
         
         @return: Returns the time seperators. 
                
     """
     
     currentTotalFileSizes = 0 
     currentTime = StatsDateLib.getSecondsSinceEpoch(startTime)
     seperators = [startTime]         
     
     if fileSizesPerHour[0] < currentFreeMemory:              
         
         for fileSizePerHour in fileSizesPerHour :
             currentTotalFileSizes = currentTotalFileSizes + fileSizePerHour
             
             if currentFreeMemory < currentTotalFileSizes:
                 seperators.append( StatsDateLib.getIsoFromEpoch(currentTime))
                 currentTotalFileSizes = 0
 
                 
             currentTime = currentTime + StatsDateLib.HOUR
     else:
         raise Exception( "Cannot build seperators. First file will not even fit within current available memory." )
         
     if seperators[len(seperators) -1 ] !=  endTime :
         seperators.append( endTime )
                 
     if len(seperators) > 2 : #If any "in between seperators were added"
         i = 1
         currentLength = len(seperators) -1
         while i < currentLength: #add 1 minute 
             if usage == "rrd":
                 seperators.insert(i+1, StatsDateLib.getIsoFromEpoch( (StatsDateLib.getSecondsSinceEpoch(seperators[i]) + StatsDateLib.MINUTE)))
             else:
                 seperators.insert( i+1, StatsDateLib.getSecondsSinceEpoch(seperators[i]) )
             currentLength = currentLength + 1
             i = i + 2
                     
     return seperators    
开发者ID:hawkeye438,项目名称:metpx,代码行数:53,代码来源:MemoryManagement.py


示例12: printPickledTimes

def printPickledTimes(pickledTimes):
    """
        @summary: Prints out all the pickled times found.
        
        @param pickledTimes: Dictionary containing containing the 
                             name -> timeOfUpdate relationships.
   
    """

    currentTime = time.time()
    currentTime = StatsDateLib.getIsoFromEpoch(currentTime)
    keys = pickledTimes.keys()
    keys.sort()

    os.system("clear")
    print "######################################################################"
    print "# List of current times of updates.                                  #"
    print "# Times were found at :  %-43s #" % currentTime
    print "# On the machine named : %-43s #" % LOCAL_MACHINE

    for key in keys:
        print ("#%32s : %33s#") % (key, pickledTimes[key])

    print "#                                                                    #"
    print "######################################################################"
开发者ID:khosrow,项目名称:metpx,代码行数:25,代码来源:picklesTimeOfUpdatesViewer.py


示例13: getPreviousMonitoringJob

 def getPreviousMonitoringJob( self, currentTime ):
     """
         @summary : Gets the previous crontab from the pickle file.
         
         @return : Time of the previous monitoring job.
         
         @warning : Returns "" if file does not exist.
         
     """     
     
     statsPaths = StatsPaths()
     statsPaths.setPaths()         
     
     file  = "%spreviousMonitoringJob" %statsPaths.STATSMONITORING
     previousMonitoringJob = ""
     
     if os.path.isfile( file ):
         fileHandle      = open( file, "r" )
         previousMonitoringJob = pickle.load( fileHandle )
         fileHandle.close()
         #print previousMonitoringJob
         
     else:
         previousMonitoringJob = StatsDateLib.getIsoTodaysMidnight( currentTime )
         
     #print previousMonitoringJob   
     
     return previousMonitoringJob        
开发者ID:hawkeye438,项目名称:metpx,代码行数:28,代码来源:StatsMonitoringConfigParameters.py


示例14: isFirstUpdateOfTheYear

 def isFirstUpdateOfTheYear( self, timeOfUpdateInIsoFormat = "" ): 
     """
         @summary : Returns whether or not an update executed at 
                    timeOfUpdateInIsoFormat would be the first update 
                    of the year.
                    
         @timeOfUpdateInIsoFormat : Time at which the update would be executed.
         
         @return : True or False.
                     
     """
     
     isFirstUpdateOfTheYear = False
     
     lastUpdateISO = self.getTimeOfLastUpdateInLogs()
     
     if timeOfUpdateInIsoFormat == "" :
         timeOfUpdateInIsoFormat = StatsDateLib.getCurrentTimeInIsoformat()
         
     if timeOfUpdateInIsoFormat >  lastUpdateISO :
         
         yearNumberOfLastUpdate    = lastUpdateISO.split("-")[0] 
         yearNumberOfCurrentUpdate = timeOfUpdateInIsoFormat.split("-")[0]  
         
         if yearNumberOfLastUpdate != yearNumberOfCurrentUpdate:
             isFirstUpdateOfTheYear = True  
     
     
     return isFirstUpdateOfTheYear
开发者ID:hawkeye438,项目名称:metpx,代码行数:29,代码来源:AutomaticUpdatesManager.py


示例15: addOptions

def addOptions( parser ):
    """
        @summary: This method is used to add all available options to the option parser.
        
    """  
    
    parser.add_option("-c", "--clients", action="store", type="string", dest="clients", default="ALL",
                        help=_("Clients' names"))
    
    parser.add_option("-d", "--daily", action="store_true", dest = "daily", default=False, help=_("Create csv file containing daily data.") )
    
    parser.add_option( "--date", action="store", type="string", dest="date", default=StatsDateLib.getIsoFromEpoch( time.time() ), help=_("Decide end time of graphics. Usefull for testing.") )
    
    parser.add_option("-f", "--fileType", action="store", type="string", dest="fileType", default='tx', help=_("Type of log files wanted.") )           
   
    parser.add_option( "--fixedPrevious", action="store_true", dest="fixedPrevious", default=False, help=_("Do not use floating weeks|days|months|years. Use previous fixed interval found.") )
   
    parser.add_option( "--fixedCurrent", action="store_true", dest="fixedCurrent", default=False, help=_("Do not use floating weeks|days|months|years. Use current fixed interval found.") )
   
    parser.add_option( "--includeGroups", action="store_true", dest="includeGroups", default=False, help=_("Include groups of all the specified machines or clusters." ) )
    
    parser.add_option( "-l", "--language", action="store", type="string", dest="outputLanguage", default="", help = _("Language in which you want the casv file to be created in." )   )
    
    parser.add_option( "--machines", action="store", type="string", dest="machines", default=LOCAL_MACHINE, help =_("Machines for wich you want to collect data." ) )
    
    parser.add_option("--machinesAreClusters", action="store_true", dest = "machinesAreClusters", default=False, help=_("Specified machines are clusters.") )
       
    parser.add_option("-m", "--monthly", action="store_true", dest = "monthly", default=False, help=_("Create csv file containing monthly data." ) )
    
    parser.add_option("--turnOffLogging", action="store_true", dest = "turnOffLogging", default=False, help=_("Turn off the logger") )
     
    parser.add_option("-w", "--weekly", action="store_true", dest = "weekly", default=False, help=_("Create csv file containing weekly data." ) )
    
    parser.add_option("-y", "--yearly", action="store_true", dest = "yearly", default=False, help=_("Create csv file containing yearly data." ) )
开发者ID:hawkeye438,项目名称:metpx,代码行数:34,代码来源:csvDataConversion.py


示例16: getStartEndOfWebPage

 def getStartEndOfWebPage():
     """
         @summary : Returns the time of the first 
                    graphics to be shown on the web 
                    page and the time of the last 
                    graphic to be displayed. 
         @return : Start,end tuple both in ISO format. 
     """
     
     currentTime = StatsDateLib.getIsoFromEpoch( time.time() )  
     
     start = StatsDateLib.rewindXDays( currentTime, NB_DAYS_DISPLAYED - 1 )
     start = StatsDateLib.getIsoTodaysMidnight( start )
          
     end   = StatsDateLib.getIsoTodaysMidnight( currentTime )
         
     return start, end 
开发者ID:hawkeye438,项目名称:metpx,代码行数:17,代码来源:DailyGraphicsWebPageGenerator.py


示例17: getStartEndOfWebPage

    def getStartEndOfWebPage():
        """
            Returns the time of the first 
            graphics to be shown on the web 
            page and the time of the last 
            graphic to be displayed. 
            
        """

        currentTime = StatsDateLib.getIsoFromEpoch(time.time())

        start = StatsDateLib.rewindXDays(currentTime, (NB_YEARS_DISPLAYED - 1) * 365)
        start = StatsDateLib.getIsoTodaysMidnight(start)

        end = StatsDateLib.getIsoTodaysMidnight(currentTime)

        return start, end
开发者ID:khosrow,项目名称:metpx,代码行数:17,代码来源:YearlyGraphicsWebPageGenerator.py


示例18: getTimeSeperatorsBasedOnAvailableMemory

def getTimeSeperatorsBasedOnAvailableMemory( startTime, endTime, clients, fileType, machines ):
    """    
        @summary: returns the time seperators to be used for the transfer 
                  in a way that should prevent overloading memory. 
        
        @param startTime: start time  of the transfer to be attempted.
        @param endTime:   end time of the transfer to be attempted.
        @param clients:   lists of clients/sources to be transferred.
        @param fileType:  tx or rx.
        @param machines:  machines on wich the clients/sources reside.
        
        @return: the time seperators.
        
    """
    
    width = 0        # Width in seconds of the transfer to be attempted
    seperators = []  # Time sperators representing every hour to be transferred.
    allFiles =[]     # List of all pickle files that will be involved
    hourlyFiles = [] # List of all files to be handled for a certain hour.
    hourlyFileSizes = [] # Total file size of all the files to be handled at a certain hour.  
    
    
    totalSizeToloadInMemory = 0.0  # Total size of all the pickle files to load in memory
    currentlyAvailableMemory = 0.0 # Total currently available memory on the present machine.
    seperatorsBasedOnAvailableMemory = [startTime, endTime] # Suppose we have all the momory we need.    

    width = ( StatsDateLib.getSecondsSinceEpoch( endTime ) -  StatsDateLib.getSecondsSinceEpoch( startTime ) ) / StatsDateLib.HOUR    
    
    seperators = [ startTime ]
    seperators.extend( StatsDateLib.getSeparatorsWithStartTime( startTime =  startTime , width= width*StatsDateLib.HOUR, interval=StatsDateLib.HOUR )[:-1])
    
    for seperator in seperators:      
        hourlyFiles = PickleMerging.createNonMergedPicklesList( seperator, machines, fileType, clients )
        allFiles.extend( hourlyFiles )        
        hourlyFileSizes.append( MemoryManagement.getTotalSizeListOfFiles( hourlyFiles )    )
    
    
    totalSizeToloadInMemory = MemoryManagement.getTotalSizeListOfFiles( allFiles )
    currentlyAvailableMemory = MemoryManagement.getCurrentFreeMemory( marginOfError = 0.75 )#never expect more than 25% of the avaiable memory to be avaiable for pickle loading.    
    
    if totalSizeToloadInMemory >= currentlyAvailableMemory:
        seperatorsBasedOnAvailableMemory = MemoryManagement.getSeperatorsForHourlyTreatments( startTime, endTime, currentlyAvailableMemory, hourlyFileSizes  )
          
    return seperatorsBasedOnAvailableMemory
开发者ID:hawkeye438,项目名称:metpx,代码行数:44,代码来源:transferPickleToRRD.py


示例19: main

def main():
    """
        @summary : This program is to be used to backup rrd databases and their corresponding
                   time of update files. Backing up rrd databases at various point in time is a
                   recommended paractice in case newly entered data is not valid. 
        
    """

    setGlobalLanguageParameters()
    
    timeToRestore = "2006-10-23 09:00:00"
    
    currentTime = time.time()        
    currentTime = StatsDateLib.getIsoFromEpoch( currentTime )
    currentTime = StatsDateLib.getIsoWithRoundedSeconds( currentTime )
    currentTime = currentTime.replace(" ", "_")
    
    generalParameters = StatsConfigParameters()
    
    generalParameters.getAllParameters()
    
    
    if len( sys.argv ) == 2:
        print     sys.argv
        #try:
        timeToRestore =  sys.argv[1]
        t =  time.strptime( timeToRestore, '%Y-%m-%d %H:%M:%S' )#will raise exception if format is wrong.
        split = timeToRestore.split()
        timeToRestore = "%s_%s" %( split[0], split[1] )
        
#         except:
#             print 'Date must be of the following format "YYYY-MM-DD HH:MM:SS"'
#             print "Program terminated."     
#             sys.exit()
                
        restoreDatabaseUpdateTimes( timeToRestore, currentTime, generalParameters.nbDbBackupsToKeep )        
        restoreDatabases( timeToRestore, currentTime, generalParameters.nbDbBackupsToKeep )    
            

    
    else:
        print _( "You must specify a date." )
        print _( "Date must be of the folowing format YYYY-MM-DD HH:MM:SS" )
        print _( "Program terminated." )
开发者ID:hawkeye438,项目名称:metpx,代码行数:44,代码来源:restoreRoundRobinDatabases.py


示例20: prepareQuery

    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() )
开发者ID:hawkeye438,项目名称:metpx,代码行数:59,代码来源:RRDQueryBroker.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python StatsPaths.StatsPaths类代码示例发布时间:2022-05-25
下一篇:
Python LanguageTools.LanguageTools类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap