#NEWLINE# @ flow . StateHandler ( ) #NEWLINE# def StoreNetstat( self , responses ) : #NEWLINE# #INDENT# 'Collect the connections and store in the datastore.\n\n    Args:\n      responses: A list of sysinfo_pb2.NetworkConnection objects.\n\n    Raises:\n      flow.FlowError: On failure to get retrieve the connections.\n    ' #NEWLINE# self . state . Register ( 'urn' , self . client_id . Add ( 'network' ) ) #NEWLINE# net_fd = aff4 . FACTORY . Create ( self . state . urn , 'Network' , token = self . token ) #NEWLINE# if responses . success : #NEWLINE# #INDENT# conns = net_fd . Schema . CONNECTIONS ( ) #NEWLINE# for response in responses : #NEWLINE# #INDENT# self . SendReply ( response ) #NEWLINE# conns . Append ( response ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise flow . FlowError ( 'Failed to get connections. Err: {0}' . format ( responses . status ) ) #NEWLINE# #UNINDENT# self . state . Register ( 'conn_count' , len ( conns ) ) #NEWLINE# net_fd . Set ( conns ) #NEWLINE# net_fd . Close ( )