aboutsummaryrefslogtreecommitdiff
path: root/sjdbmk/sendmail.py
diff options
context:
space:
mode:
Diffstat (limited to 'sjdbmk/sendmail.py')
-rw-r--r--sjdbmk/sendmail.py55
1 files changed, 42 insertions, 13 deletions
diff --git a/sjdbmk/sendmail.py b/sjdbmk/sendmail.py
index 4b58674..b966e49 100644
--- a/sjdbmk/sendmail.py
+++ b/sjdbmk/sendmail.py
@@ -70,7 +70,9 @@ def sendmail(
raise TypeError("Naive datetimes are no longer supported")
utcwhen = when.astimezone(datetime.timezone.utc)
isoval = utcwhen.isoformat(timespec="seconds").replace("+00:00", "Z")
- data["singleValueExtendedProperties"] = [{"id": "SystemTime 0x3FEF", "value": isoval}]
+ data["singleValueExtendedProperties"] = [
+ {"id": "SystemTime 0x3FEF", "value": isoval}
+ ]
if not reply_to:
response = requests.post(
@@ -110,7 +112,8 @@ def sendmail(
if response2.status_code != 202:
pprint(response2.content.decode("utf-8", "replace"))
raise ValueError(
- "Graph response to messages/%s/send returned something other than 202 Accepted" % response["id"],
+ "Graph response to messages/%s/send returned something other than 202 Accepted"
+ % response["id"],
)
return msgid
@@ -136,14 +139,20 @@ def main() -> None:
action="store_true",
help="Send the bulletin right now, instead of at the right time",
)
- parser.add_argument("--config", default="config.ini", help="path to the configuration file")
+ parser.add_argument(
+ "--config", default="config.ini", help="path to the configuration file"
+ )
args = parser.parse_args()
config = ConfigParser()
config.read(args.config)
if args.date:
- date = datetime.datetime.strptime(args.date, "%Y-%m-%d").replace(tzinfo=zoneinfo.ZoneInfo(config["general"]["timezone"]))
+ date = datetime.datetime.strptime(args.date, "%Y-%m-%d").replace(
+ tzinfo=zoneinfo.ZoneInfo(config["general"]["timezone"])
+ )
else:
- date = datetime.datetime.now(zoneinfo.ZoneInfo(config["general"]["timezone"])) + datetime.timedelta(days=1)
+ date = datetime.datetime.now(
+ zoneinfo.ZoneInfo(config["general"]["timezone"])
+ ) + datetime.timedelta(days=1)
os.chdir(config["general"]["build_path"])
@@ -160,11 +169,16 @@ def main() -> None:
if not args.reply:
a = sendmail(
token,
- subject=config["sendmail"]["subject_format"] % date.strftime(config["sendmail"]["subject_date_format"]),
+ subject=config["sendmail"]["subject_format"]
+ % date.strftime(config["sendmail"]["subject_date_format"]),
body=html,
to=config["sendmail"]["to_1"].split(" "),
cc=config["sendmail"]["cc_1"].split(" "),
- bcc=[w.strip() for w in open(config["sendmail"]["bcc_1_file"], "r").readlines() if w.strip()],
+ bcc=[
+ w.strip()
+ for w in open(config["sendmail"]["bcc_1_file"], "r").readlines()
+ if w.strip()
+ ],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -180,11 +194,16 @@ def main() -> None:
fd.write(a)
b = sendmail(
token,
- subject=config["sendmail"]["subject_format"] % date.strftime(config["sendmail"]["subject_date_format"]),
+ subject=config["sendmail"]["subject_format"]
+ % date.strftime(config["sendmail"]["subject_date_format"]),
body=html,
to=config["sendmail"]["to_2"].split(" "),
cc=config["sendmail"]["cc_2"].split(" "),
- bcc=[w.strip() for w in open(config["sendmail"]["bcc_2_file"], "r").readlines() if w.strip()],
+ bcc=[
+ w.strip()
+ for w in open(config["sendmail"]["bcc_2_file"], "r").readlines()
+ if w.strip()
+ ],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -203,11 +222,16 @@ def main() -> None:
last_a = fd.read().strip()
a = sendmail(
token,
- subject=config["sendmail"]["subject_format"] % date.strftime(config["sendmail"]["subject_date_format"]),
+ subject=config["sendmail"]["subject_format"]
+ % date.strftime(config["sendmail"]["subject_date_format"]),
body=html,
to=config["sendmail"]["to_1"].split(" "),
cc=config["sendmail"]["cc_1"].split(" "),
- bcc=[w.strip() for w in open(config["sendmail"]["bcc_1_file"], "r").readlines() if w.strip()],
+ bcc=[
+ w.strip()
+ for w in open(config["sendmail"]["bcc_1_file"], "r").readlines()
+ if w.strip()
+ ],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -226,11 +250,16 @@ def main() -> None:
last_b = fd.read().strip()
b = sendmail(
token,
- subject=config["sendmail"]["subject_format"] % date.strftime(config["sendmail"]["subject_date_format"]),
+ subject=config["sendmail"]["subject_format"]
+ % date.strftime(config["sendmail"]["subject_date_format"]),
body=html,
to=config["sendmail"]["to_2"].split(" "),
cc=config["sendmail"]["cc_2"].split(" "),
- bcc=[w.strip() for w in open(config["sendmail"]["bcc_2_file"], "r").readlines() if w.strip()],
+ bcc=[
+ w.strip()
+ for w in open(config["sendmail"]["bcc_2_file"], "r").readlines()
+ if w.strip()
+ ],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),