#NEWLINE# def _WrapContentGenerator( self , generator , collection , args , token = None ) : #NEWLINE# #INDENT# user = aff4 . FACTORY . Create ( aff4 . ROOT_URN . Add ( 'users' ) . Add ( token . username ) , aff4_type = aff4_users . GRRUser . __name__ , mode = 'rw' , token = token ) #NEWLINE# try : #NEWLINE# #INDENT# for item in generator . Generate ( collection , token = token ) : #NEWLINE# #INDENT# ( yield item ) #NEWLINE# #UNINDENT# user . Notify ( 'ArchiveGenerationFinished' , None , ( 'Downloaded archive of hunt %s results (archived %d out of %d items, archive size is %d)' % ( args . hunt_id . Basename ( ) , generator . archived_files , user . total_files , generator . output_size ) ) , self . __class__ . __name__ ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# user . Notify ( 'Error' , None , ( 'Archive generation failed for hunt %s: %s' % ( args . hunt_id . Basename ( ) , utils . SmartStr ( e ) ) ) , self . __class__ . __name__ ) #NEWLINE# raise #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# user . Close ( )