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


Python StatsDateLib.getStartEndFromPreviousMonth方法代碼示例

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


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

示例1: getOptionsFromParser

# 需要導入模塊: from pxStats.lib.StatsDateLib import StatsDateLib [as 別名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import getStartEndFromPreviousMonth [as 別名]
def getOptionsFromParser( parser ):
    """
        @summary: Parses and validates the options found in the parser. 
        
        @return: If information was found to be valid, return options
    
    """
    
    infos = None 
    date   = []
    
    ( options, args )= parser.parse_args()        
    machines         = options.machines.replace( ' ','').split(',')
    date             = options.date.replace('"','').replace("'",'')
    fileType         = options.fileType.replace("'",'')
    daily            = options.daily
    weekly           = options.weekly
    monthly          = options.monthly
    yearly           = options.yearly    
    fixedCurrent     = options.fixedCurrent
    fixedPrevious    = options.fixedPrevious
    turnOffLogging   = options.turnOffLogging
    includeGroups    = options.includeGroups
    machinesAreClusters = options.machinesAreClusters
    outputLanguage      = options.outputLanguage
    
    
    
    if fixedPrevious and fixedCurrent:
        print _("Error. Please use only one of the fixed options,either fixedPrevious or fixedCurrent. " )
        print _("Use -h for help.")
        print _("Program terminated.")
        sys.exit()  
    
    counter = 0  
    specialParameters = [daily, monthly, weekly, yearly]
    for specialParameter in specialParameters:
        if specialParameter:
            counter = counter + 1 
            
    if counter > 1 :
        print _( "Error. Only one of the daily, weekly and yearly options can be use at a time " )
        print _( "Use -h for help." )
        print _( "Program terminated." )
        sys.exit()
        
    elif counter == 0:    
        print _( "Error. Please use either the -d -m -w or -y options. " )
        print _( "Use -h for help." )
        print _( "Program terminated." )
        sys.exit()
         



    try: # Makes sure date is of valid format. 
         # Makes sure only one space is kept between date and hour.
        t =  time.strptime( date, '%Y-%m-%d %H:%M:%S' )
        split = date.split()
        date = "%s %s" %( split[0], split[1] )

    except:    
        print _( "Error. The date format must be YYYY-MM-DD HH:MM:SS" )
        print _( "Use -h for help." )
        print _( "Program terminated." )
        sys.exit()         
        
         
    #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"
#.........這裏部分代碼省略.........
開發者ID:hawkeye438,項目名稱:metpx,代碼行數:103,代碼來源:csvDataConversion.py


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