1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: error handling in mailing script [skip ci]

This commit is contained in:
Ferdinand Mütsch 2023-01-23 16:23:18 +01:00
parent c42985a279
commit 749782b15b

View File

@ -1,4 +1,5 @@
import argparse import argparse
import logging
import time import time
import requests import requests
@ -36,8 +37,11 @@ def send(recipient: str, subject: str, content: str, is_html: bool = False, base
def run(args): def run(args):
content, is_html = read_mail_content(args.content) content, is_html = read_mail_content(args.content)
for recipient in tqdm(read_recipients(args.recipients)): for recipient in tqdm(read_recipients(args.recipients)):
try:
send(recipient, args.subject, content, is_html, args.mw_url) send(recipient, args.subject, content, is_html, args.mw_url)
time.sleep(args.throttle) time.sleep(args.throttle)
except Exception as e:
logging.warning(f'failed to send to {recipient}, {e}')
def parse_arguments(): def parse_arguments():