#NEWLINE# @ flow . StateHandler ( ) #NEWLINE# def Start( self ) : #NEWLINE# #INDENT# with aff4 . FACTORY . Open ( self . args . hunt_urn , aff4_type = 'GRRHunt' , mode = 'rw' , token = self . token ) as hunt : #NEWLINE# #INDENT# if ( self . token . username != hunt . creator ) : #NEWLINE# #INDENT# data_store . DB . security_manager . CheckHuntAccess ( self . token . RealUID ( ) , self . args . hunt_urn ) #NEWLINE# #UNINDENT# if hunt . GetRunner ( ) . IsHuntStarted ( ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Unable to delete a running hunt.' ) #NEWLINE# #UNINDENT# if ( ( not config_lib . CONFIG [ 'AdminUI.allow_hunt_results_delete' ] ) and hunt . client_count ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Unable to delete a hunt with results while AdminUI.allow_hunt_results_delete is disabled.' ) #NEWLINE# #UNINDENT# #UNINDENT# aff4 . FACTORY . Delete ( self . args . hunt_urn , token = self . token )