當前位置: 首頁>>代碼示例>>Python>>正文


Python StatsDateLib.getStartEndFromCurrentMonth方法代碼示例

本文整理匯總了Python中pxStats.lib.StatsDateLib.StatsDateLib.getStartEndFromCurrentMonth方法的典型用法代碼示例。如果您正苦於以下問題:Python StatsDateLib.getStartEndFromCurrentMonth方法的具體用法?Python StatsDateLib.getStartEndFromCurrentMonth怎麽用?Python StatsDateLib.getStartEndFromCurrentMonth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pxStats.lib.StatsDateLib.StatsDateLib的用法示例。


在下文中一共展示了StatsDateLib.getStartEndFromCurrentMonth方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getOptionsFromParser

# 需要導入模塊: from pxStats.lib.StatsDateLib import StatsDateLib [as 別名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndFromCurrentMonth [as 別名]

#.........這裏部分代碼省略.........
        
         
    #TODO :fixStartEnd method???    
    if fixedPrevious :
        if daily :
            span = "daily"
            graphicType = "daily"
            start, end = StatsDateLib.getStartEndFromPreviousDay( date )             
        elif weekly:
            span = "weekly"
            graphicType = "weekly"
            start, end = StatsDateLib.getStartEndFromPreviousWeek( date )
        elif monthly:
            span = "monthly"
            graphicType = "monthly"
            start, end = StatsDateLib.getStartEndFromPreviousMonth( date )
        elif yearly:
            span = "yearly" 
            graphicType = "yearly" 
            start, end = StatsDateLib.getStartEndFromPreviousYear( date )
        timeSpan = int( StatsDateLib.getSecondsSinceEpoch( end ) - StatsDateLib.getSecondsSinceEpoch( start ) ) / 3600
             
    elif fixedCurrent:
        if daily :
            span = "daily"
            graphicType = "daily"
            start, end = StatsDateLib.getStartEndFromCurrentDay( date )   
        elif weekly:
            span = "weekly"
            graphicType = "weekly"
            start, end = StatsDateLib.getStartEndFromCurrentWeek( date )
        elif monthly:
            span = "monthly"
            graphicType = "monthly"
            start, end = StatsDateLib.getStartEndFromCurrentMonth( date )    
        elif yearly:
            span = "yearly" 
            graphicType = "yearly" 
            start, end = StatsDateLib.getStartEndFromCurrentYear( date ) 
        timeSpan = int( StatsDateLib.getSecondsSinceEpoch( end ) - StatsDateLib.getSecondsSinceEpoch( start ) ) / 3600
        
    else:       
        #TODO fix span method???   
        if daily :
            timeSpan = 24  
            graphicType = "daily"  
            span = "daily"    
        elif weekly:
            timeSpan = 24 * 7  
            graphicType = "weekly" 
            span = "weekly" 
        elif monthly:
            timeSpan = 24 * 30 
            graphicType = "monthly"
            span = "monthly"       
        elif yearly:            
            timeSpan = 24 * 365
            graphicType = "yearly"  
            span = "yearly"
            
        start = StatsDateLib.getIsoFromEpoch( StatsDateLib.getSecondsSinceEpoch( date ) - timeSpan*60*60 ) 
        end   = date                       
            
     
         
    if fileType != "tx" and fileType != "rx":
        print _("Error. File type must be either tx or rx.")
        print _('Multiple types are not accepted.' )
        print _("Use -h for additional help.")
        print _("Program terminated.")
        sys.exit()    

    if includeGroups == True:
        configParameters = StatsConfigParameters()
        configParameters.getAllParameters()
        groups = configParameters.groupParameters.groups
        machinesToSearch = machines[:]#Forces a copy and nota reference.
        for machine in machines:
            if machinesAreClusters == True :
                machineConfig = MachineConfigParameters()
                machineConfig.getParametersFromMachineConfigurationFile()
                machinesAssociatedWith = machineConfig.getMachinesAssociatedWith( machine ) 
                machinesToTest = str(machinesAssociatedWith).replace('[','').replace(']', '').replace(',','').replace( "'",'' ).replace('"','' ).\
                                 replace(" ",'').replace('[','').replace(']', '').replace(',','').replace( "'",'' ).replace('"','' ).replace(" ",'')       
            
             
            for group in groups:
                groupsMachine =  str( configParameters.groupParameters.groupsMachines[group] ).replace('[','').replace(']', '').\
                                 replace(',','').replace( "'",'' ).replace('"','' ).replace(" ",'')
                #print   "machinesToTest %s groupsMachine %s" %(machinesToTest,groupsMachine ) 
                if machinesToTest in groupsMachine :
                    if groupsMachine not in machinesToSearch:
                        machinesToSearch.append(groupsMachine)
    
    
    #print machines
    infos = _CsvInfos( start = start , end = end  , span = span, timeSpan = timeSpan, fileType = fileType, machinesForLabels = machines,\
                       machinesToSearch = machinesToSearch, machinesAreClusters = machinesAreClusters, dataSource = "databases", outputLanguage = outputLanguage )    
    
    return infos
開發者ID:hawkeye438,項目名稱:metpx,代碼行數:104,代碼來源:csvDataConversion.py


注:本文中的pxStats.lib.StatsDateLib.StatsDateLib.getStartEndFromCurrentMonth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。