当前位置: 首页>>代码示例>>Python>>正文


Python StatsDateLib.isoDateDashed方法代码示例

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


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

示例1: findValues

# 需要导入模块: from pxStats.lib.StatsDateLib import StatsDateLib [as 别名]
# 或者: from pxStats.lib.StatsDateLib.StatsDateLib import isoDateDashed [as 别名]
    def findValues( statsTypes, line = "", lineType = "[INFO]", fileType = "tx",logger = None ):
        """
            @summary : This method is used to find specific values within a line. 
            
            @note    : If stats type cannot be found the 0 value will be returned.  
                       A key named "valuesNotFound" will be added. It's value will 
                       be an array containing the list of statsType for which no 
                       values were found.
            
            @precondition: Requires _ translator to have been set prior to calling this function.
            
            @return : returns a dictionary containing the statsType->foundValue associations.
        
                       
            
        """
       
        global _ 
        
        values = {} #in case of an unknown type
        
        splitLine = line.split( " " )
        
        
        if line != "" and line != "\n" :
                       
            for statsType in statsTypes :  
                
                try:                    
                    
                    if statsType == "departure" : #is at the same place for every lineType 
                        values[ statsType ] =  line.split( "," )[0]   
                        
                    
                    elif lineType == "[INFO]" :
                        
                        if statsType == "latency":
                                                            
                            d1 = line[:19]
                            d2 = splitLine[6].split(":")[6]     
                                    
                            result = (datetime.datetime( int(d1[0:4]), int(d1[5:7]), int(d1[8:10]), int(d1[11:13]), int(d1[14:16]), int(d1[17:19])) - datetime.datetime( int(d2[0:4]),int(d2[4:6]),int(d2[6:8]),int(d2[8:10]),int(d2[10:12]),int(d2[12:14]) ) )                          
                            
                            values[statsType] = result.seconds + (result.days*24*60*60)
                            if values[statsType] < 0 :
                                values[statsType] = 0 
                                      
                        elif statsType == "arrival":                  
                        
                            values[statsType] = StatsDateLib.isoDateDashed( splitLine[6].split( ":" )[6] )    
    
                                
                        elif statsType == "bytecount":
                            start = line.find( "(" )
                            end   = line.find( "Bytes" )  
                            start = start +1
                            end = end -1                           
                            
                            values[statsType] = int( line[start:end] )
                        
                            
                        elif statsType == "fileName":
                            
                            if fileType == "tx" :
                                values[statsType] = os.path.basename(splitLine[6])#.split( ":" )[0]
                            else:
                                split     = line.split( "/" )
                                lastPart  = split[ len( split ) -1 ]
                                values[ statsType ] = lastPart.split( ":" )[0] #in case something is added after line ends.
                            
                        elif statsType == "productType":
                            
                            if fileType == "tx":
                                values[statsType] = os.path.basename(splitLine[6])#.split( ":" )[0]
                            else: # rx has a very different format for product.
                                split     = line.split( "/" )
                                lastPart  = split[ len( split ) -1 ]
                                values[ statsType ] = lastPart.split( ":" )[0] #in case something is added after line ends.
                                
                        elif statsType == "errors" :
                            values[statsType] = 0  
                            
                        
                    elif lineType == "[ERROR]":
                    
                        if statsType == "errors" :
                            values[statsType] = 1                   
            
                        
                        elif statsType == "productType" :     
                            values[statsType] = ""
                        else:
                            values[statsType] = 0
                        
                        #elif lineType == "[OTHER]" :               
            
                except:                
                    
                    if logger is not None :
                        logger.error(_("could not find %s value in line %s.") %( statsType,line ) ) 
#.........这里部分代码省略.........
开发者ID:hawkeye438,项目名称:metpx,代码行数:103,代码来源:FileStatsCollector.py


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