#NEWLINE# def currentSpeed( self , i3s_output_list , i3s_config ) : #NEWLINE# #INDENT# if ( not isinstance ( self . interfaces , list ) ) : #NEWLINE# #INDENT# self . interfaces = self . interfaces . split ( ',' ) #NEWLINE# #UNINDENT# if ( not isinstance ( self . interfaces_blacklist , list ) ) : #NEWLINE# #INDENT# self . interfaces_blacklist = self . interfaces_blacklist . split ( ',' ) #NEWLINE# #UNINDENT# if ( self . precision > 0 ) : #NEWLINE# #INDENT# self . left_align = ( ( len ( str ( MULTIPLIER_TOP ) ) + 1 ) + self . precision ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . left_align = len ( str ( MULTIPLIER_TOP ) ) #NEWLINE# #UNINDENT# self . value_format = ( '{value:%s.%sf} {unit}' % ( self . left_align , self . precision ) ) #NEWLINE# ns = self . _get_stat ( ) #NEWLINE# deltas = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# timedelta = ( time ( ) - self . last_time ) #NEWLINE# for ( old , new ) in zip ( self . last_stat , ns ) : #NEWLINE# #INDENT# down = ( int ( new [ 1 ] ) - int ( old [ 1 ] ) ) #NEWLINE# up = ( int ( new [ 9 ] ) - int ( old [ 9 ] ) ) #NEWLINE# down /= ( timedelta * INITIAL_MULTI ) #NEWLINE# up /= ( timedelta * INITIAL_MULTI ) #NEWLINE# deltas [ new [ 0 ] ] = { #NEWLINE# #INDENT# 'total' : ( up + down ) , #NEWLINE# 'up' : up , #NEWLINE# 'down' : down , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# self . last_stat = self . _get_stat ( ) #NEWLINE# self . last_time = time ( ) #NEWLINE# interface = max ( deltas , key = ( lambda x : deltas [ x ] [ 'total' ] ) ) #NEWLINE# if ( deltas [ interface ] [ 'total' ] == 0 ) : #NEWLINE# #INDENT# interface = self . last_interface #NEWLINE# hide = self . hide_if_zero #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . last_interface = interface #NEWLINE# hide = False #NEWLINE# #UNINDENT# delta = ( deltas [ interface ] if interface else None ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# delta = None #NEWLINE# interface = None #NEWLINE# hide = self . hide_if_zero #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'cached_until' : ( time ( ) + old . cache_timeout ) , #NEWLINE# 'full_text' : ( '' if hide else ( self . format . format ( total = self . _divide_and_format ( delta [ 'total' ] ) , up = self . _divide_and_format ( delta [ 'up' ] ) , down = self . _divide_and_format ( delta [ 'down' ] ) , interface = interface [ : ( - 1 ) ] ) if interface else self . format_no_connection ) ) , #NEWLINE# #UNINDENT# }