#NEWLINE# def publish_status( self , target , temp , heater_percent , cooler_percent ) : #NEWLINE# #INDENT# timestamp = int ( time . time ( ) ) #NEWLINE# status = [ target , temp , heater_percent , cooler_percent , timestamp ] #NEWLINE# self . _datapoints . append ( status ) #NEWLINE# earliest = ( timestamp - self . _past_seconds ) #NEWLINE# self . _datapoints = [ d for d in self . _datapoints if ( d [ 4 ] >= earliest ) ] #NEWLINE# if ( len ( self . _datapoints ) >= 2 ) : #NEWLINE# #INDENT# freq_seconds = ( self . _datapoints [ ( - 1 ) ] [ 4 ] - self . _datapoints [ ( - 2 ) ] [ 4 ] ) #NEWLINE# if ( freq_seconds > 0 ) : #NEWLINE# #INDENT# self . _chart_config . x_labels_major_every = ( self . _x_label_seconds / freq_seconds ) #NEWLINE# #UNINDENT# #UNINDENT# chart = pygal . Line ( self . _chart_config ) #NEWLINE# chart . x_labels = [ datetime . fromtimestamp ( d [ 4 ] ) . strftime ( '%b-%d %H:%M:%S' ) for d in self . _datapoints ] #NEWLINE# chart . add ( 'Target' , [ d [ 0 ] for d in self . _datapoints ] ) #NEWLINE# chart . add ( 'Actual' , [ d [ 1 ] for d in self . _datapoints ] ) #NEWLINE# try : #NEWLINE# #INDENT# getattr ( chart , self . _outputter ) ( filename = self . _out_file ) #NEWLINE# #UNINDENT# except IOError as err : #NEWLINE# #INDENT# raise OutputError ( err )