#NEWLINE# @ flow . StateHandler ( ) #NEWLINE# def Start( self ) : #NEWLINE# #INDENT# 'Retrieve all the clients for the AbstractClientStatsCollectors.' #NEWLINE# try : #NEWLINE# #INDENT# self . stats = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . BeginProcessing ( ) #NEWLINE# root = aff4 . FACTORY . Open ( aff4 . ROOT_URN , token = self . token ) #NEWLINE# children_urns = list ( root . ListChildren ( ) ) #NEWLINE# logging . debug ( 'Found %d children.' , len ( children_urns ) ) #NEWLINE# processed_count = 0 #NEWLINE# for child in aff4 . FACTORY . MultiOpen ( children_urns , mode = 'r' , token = self . token , age = aff4 . NEWEST_TIME ) : #NEWLINE# #INDENT# if isinstance ( child , aff4 . AFF4Object . VFSGRRClient ) : #NEWLINE# #INDENT# self . ProcessClient ( child ) #NEWLINE# processed_count += 1 #NEWLINE# #UNINDENT# self . HeartBeat ( ) #NEWLINE# #UNINDENT# self . FinishProcessing ( ) #NEWLINE# for fd in self . stats . values ( ) : #NEWLINE# #INDENT# fd . Close ( ) #NEWLINE# #UNINDENT# logging . info ( '%s: processed %d clients.' , self . __class__ . __name__ , processed_count ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logging . exception ( 'Error while calculating stats: %s' , e ) #NEWLINE# raise