1313import os , cv2
1414import tarfile
1515
16- # Create a TinyDB instance for storing previous alert hashes
17- db = TinyDB ('previous_alerts.json' )
18-
1916data_sources = ['s3' , 'mysql' , 'redis' , 'firebase' , 'gcs' , 'fs' , 'postgresql' , 'mongodb' , 'slack' , 'couchdb' , 'gdrive' , 'gdrive_workspace' , 'text' ]
2017data_sources_option = ['all' ] + data_sources
2118
2724parser .add_argument ('--stdout' , action = 'store_true' , help = 'Print output to stdout' )
2825parser .add_argument ('--quiet' , action = 'store_true' , help = 'Print only the results' )
2926parser .add_argument ('--debug' , action = 'store_true' , help = 'Enable debug mode' )
27+ parser .add_argument ('--no-write' , action = 'store_true' , help = 'Do not write previous alerts to file, this may flood you with duplicate alerts' )
3028parser .add_argument ('--shutup' , action = 'store_true' , help = 'Suppress the Hawk Eye banner 🫣' , default = False )
3129
3230args = parser .parse_args ()
3331
32+ # Create a TinyDB instance for storing previous alert hashes
33+ db = None
34+
35+ if not args .no_write :
36+ db = TinyDB ('previous_alerts.json' )
37+
3438if args .quiet :
3539 args .shutup = True
3640
@@ -393,7 +397,7 @@ def SlackNotify(msg):
393397 # Check if suppress_duplicates is set to True
394398 suppress_duplicates = notify_config .get ('suppress_duplicates' , False )
395399
396- if suppress_duplicates :
400+ if suppress_duplicates and not args . no_write :
397401 # Calculate the hash of the message
398402 msg_hash = calculate_msg_hash (msg )
399403
@@ -413,7 +417,7 @@ def SlackNotify(msg):
413417 headers = {'Content-Type' : 'application/json' }
414418 requests .post (webhook_url , data = json .dumps (payload ), headers = headers )
415419
416- if suppress_duplicates :
420+ if suppress_duplicates and not args . no_write :
417421 # Store the message hash in the previous alerts database
418422 db .insert ({'msg_hash' : msg_hash })
419423 except Exception as e :
0 commit comments