From 7873b964bdabba54deea3058b15014f544fc455c Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 25 Dec 2022 02:19:14 -0500 Subject: [PATCH] Use `subprocess.run()` `encoding` argument instead of manual encode/decode --- mailman_sync.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mailman_sync.py b/mailman_sync.py index efbf539..9bb679b 100755 --- a/mailman_sync.py +++ b/mailman_sync.py @@ -12,7 +12,7 @@ import requests def sync_members(mailman_bin: Path, mailing_list: str, members: list[str]): - members_data = "\n".join(members).encode('ascii') + members_data = "\n".join(members) output = subprocess.run( [ mailman_bin / "sync_members", @@ -25,10 +25,11 @@ def sync_members(mailman_bin: Path, mailing_list: str, members: list[str]): mailing_list, ], input=members_data, + encoding="ascii", capture_output=True, check=True, ) - print(output.stdout.decode('ascii')) + print(output.stdout) def main(mailman_bin: Path, api: str, token: str, list_suffix: str): @@ -38,8 +39,11 @@ def main(mailman_bin: Path, api: str, token: str, list_suffix: str): return existing_lists = subprocess.run( - [mailman_bin / "list_lists", "-b"], capture_output=True, check=True - ).stdout.decode('ascii').split("\n") + [mailman_bin / "list_lists", "-b"], + encoding="ascii", + capture_output=True, + check=True, + ).stdout.split("\n") certification_lists = r.json() for name, members in certification_lists.items(): list_name = name + list_suffix