#NEWLINE# def delete( self , args ) : #NEWLINE# #INDENT# sys . stdout . write ( 'Counting alerts: ' ) #NEWLINE# response = self . _counts ( args . filters ) #NEWLINE# total = response [ 'total' ] #NEWLINE# sys . stdout . write ( ( '%s, done.\n' % total ) ) #NEWLINE# sys . stdout . write ( 'Deleting alerts: ' ) #NEWLINE# response = self . _alerts ( args . filters ) #NEWLINE# alerts = e [ 'alerts' ] #NEWLINE# for ( i , alert ) in enumerate ( alerts ) : #NEWLINE# #INDENT# pct = int ( ( ( 100.0 * i ) / total ) ) #NEWLINE# sys . stdout . write ( ( '%3d%% (%d/%d)' % ( pct , i , total ) ) ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# sys . stdout . write ( ( '\x08' * ( ( 8 + len ( str ( i ) ) ) + len ( str ( total ) ) ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . api . delete_alert ( alert [ 'id' ] ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# print ( ) #NEWLINE# LOG . error ( e ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# sys . stdout . write ( ( '100%% (%d/%d), done.\n' % ( total , total ) ) )