#NEWLINE# def push( self , statsDict = None , prefix = None , path = None ) : #NEWLINE# #INDENT# 'Push stat values out to Graphite.' #NEWLINE# if ( statsDict is None ) : #NEWLINE# #INDENT# statsDict = scales . getStats ( ) #NEWLINE# #UNINDENT# prefix = ( prefix or self . prefix ) #NEWLINE# path = ( path or '/' ) #NEWLINE# for ( name , value ) in list ( statsDict . items ( ) ) : #NEWLINE# #INDENT# name = str ( name ) #NEWLINE# subpath = os . path . join ( path , name ) #NEWLINE# if self . _pruned ( subpath ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if hasattr ( value , '__call__' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# value = value ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# value = None #NEWLINE# log . exception ( 'Error when calling stat function for graphite push' ) #NEWLINE# #UNINDENT# #UNINDENT# if hasattr ( value , 'items' ) : #NEWLINE# #INDENT# self . push ( value , ( '%s%s.' % ( prefix , self . _sanitize ( name ) ) ) , subpath ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . _forbidden ( subpath , value ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# if six . PY3 : #NEWLINE# #INDENT# type_values = ( int , float ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# type_values = ( int , long , float ) #NEWLINE# #UNINDENT# if ( ( type ( value ) in type_values ) and ( len ( prefix ) < 500 ) ) : #NEWLINE# #INDENT# self . graphite . log ( ( prefix + self . _sanitize ( name ) ) , value )