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, 15 insertions, 40 deletions
diff --git a/sjdbmk/sendmail.py b/sjdbmk/sendmail.py
index ddd6f32..363efe9 100644
--- a/sjdbmk/sendmail.py
+++ b/sjdbmk/sendmail.py
@@ -74,9 +74,7 @@ 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(
@@ -116,8 +114,7 @@ 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
@@ -138,19 +135,17 @@ def main() -> None:
help="Reply to the previous bulletin when sending (BROKEN)",
)
parser.add_argument(
- "--config", default="config.ini", help="path to the configuration file"
+ "--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"])
@@ -167,16 +162,11 @@ 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_and_readlines(config["sendmail"]["bcc_1_file"])
- if w.strip()
- ],
+ bcc=[w.strip() for w in open_and_readlines(config["sendmail"]["bcc_1_file"]) if w.strip()],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -191,16 +181,11 @@ 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_and_readlines(config["sendmail"]["bcc_2_file"])
- if w.strip()
- ],
+ bcc=[w.strip() for w in open_and_readlines(config["sendmail"]["bcc_2_file"]) if w.strip()],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -218,16 +203,11 @@ 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_and_readlines(config["sendmail"]["bcc_1_file"])
- if w.strip()
- ],
+ bcc=[w.strip() for w in open_and_readlines(config["sendmail"]["bcc_1_file"]) if w.strip()],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),
@@ -245,16 +225,11 @@ 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_and_readlines(config["sendmail"]["bcc_2_file"])
- if w.strip()
- ],
+ bcc=[w.strip() for w in open_and_readlines(config["sendmail"]["bcc_2_file"]) if w.strip()],
when=date.replace(
hour=int(config["sendmail"]["hour"]),
minute=int(config["sendmail"]["minute"]),