PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /opt/sharedrads/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //opt/sharedrads/exclude_sender |
#!/opt/imh-python/bin/python3 import json import argparse from os import path from datetime import datetime, timedelta parser = argparse.ArgumentParser( description='Add or remove temporary exclusion from sender_volume crit.' ) parser.add_argument( 'Sender', metavar='sender', type=str, help='Email address to ignore.' ) parser.add_argument( '-t', action='store', metavar='hours', type=int, default=1, help='Number of hours to exclude a sender from the crit, Default 1, Max 6.', ) parser.add_argument( '--d', action='store_const', metavar='delete', default=False, const=True, help='Delete the exclusion for the specified user.', ) args = parser.parse_args() def get_exclusion_data(): if path.exists("/tmp/sender_volume.json"): try: with open('/tmp/sender_volume.json') as exclude_json: data = json.load(exclude_json) except Exception: data = {} else: data = {} return data def write_exclusion_file(data): with open('/tmp/sender_volume.json', 'w') as exclusion_file: json.dump(data, exclusion_file) def main(): data = get_exclusion_data() if args.d is False: if args.t > 6: expire_time = datetime.now() + timedelta(hours=1) else: expire_time = datetime.now() + timedelta(hours=args.t) data[args.Sender] = str(expire_time) if args.d is True: if args.Sender in data: del data[args.Sender] write_exclusion_file(data) if __name__ == '__main__': main()