<s> """<STR_LIT>""" <EOL> from grr . lib import aff4 <EOL> from grr . lib import data_store <EOL> from grr . lib import flow <EOL> from grr . lib import utils <EOL> from grr . lib . aff4_objects import timeline <EOL> from grr . lib . rdfvalues import client as rdf_client <EOL> from grr . lib . rdfvalues import structs as rdf_structs <EOL> from grr . proto import flows_pb2 <EOL> class MACTimesArgs ( rdf_structs . RDFProtoStruct ) : <EOL> protobuf = flows_pb2 . MACTimesArgs <EOL> class MACTimes ( flow . GRRFlow ) : <EOL> """<STR_LIT>""" <EOL> category = "<STR_LIT>" <EOL> behaviours = flow . GRRFlow . behaviours + "<STR_LIT>" <EOL> args_type = MACTimesArgs <EOL> @ flow . StateHandler ( next_state = "<STR_LIT>" ) <EOL> def Start ( self ) : <EOL> """<STR_LIT>""" <EOL> self . state . Register ( "<STR_LIT>" , self . client_id . Add ( self . args . path ) ) <EOL> if self . runner . output is not None : <EOL> self . runner . output = aff4 . FACTORY . Create ( <EOL> self . runner . output . urn , "<STR_LIT>" , token = self . token ) <EOL> self . runner . output . Set ( <EOL> self . runner . output . Schema . DESCRIPTION ( <EOL> "<STR_LIT>" . format ( self . args . path ) ) ) <EOL> self . CallState ( next_state = "<STR_LIT>" ) <EOL> def _ListVFSChildren ( self , fds ) : <EOL> """<STR_LIT>""" <EOL> child_urns = [ ] <EOL> while <NUM_LIT:1> : <EOL> direct_children = [ ] <EOL> for _ , children in aff4 . FACTORY . MultiListChildren ( <EOL> fds , token = self . token ) : <EOL> direct_children . extend ( children ) <EOL> if not direct_children : <EOL> break <EOL> child_urns . extend ( direct_children ) <EOL> fds = direct_children <EOL> return child_urns <EOL> @ flow . StateHandler ( ) <EOL> def CreateTimeline ( self ) : <EOL> """<STR_LIT>""" <EOL> child_urns = self . _ListVFSChildren ( [ self . state . urn ] ) <EOL> attribute = aff4 . Attribute . GetAttributeByName ( "<STR_LIT>" ) <EOL> for subject , values in data_store . DB . MultiResolvePrefix ( <EOL> child_urns , attribute . predicate , token = self . token , limit = <NUM_LIT> ) : <EOL> for _ , serialized , _ in values : <EOL> stat = rdf_client . StatEntry ( serialized ) <EOL> event = timeline . Event ( source = utils . SmartUnicode ( subject ) , <EOL> stat = stat ) <EOL> for c in "<STR_LIT>" : <EOL> timestamp = getattr ( stat , "<STR_LIT>" % c ) <EOL> if timestamp is not None : <EOL> event . timestamp = timestamp * <NUM_LIT> <EOL> event . type = "<STR_LIT>" % c <EOL> event . subject = utils . SmartUnicode ( subject ) <EOL> if self . runner . output is not None : <EOL> self . runner . output . AddEvent ( event ) </s>
