diff --git a/mailman_sync.py b/mailman_sync.py index cd2533a..d1db2c5 100755 --- a/mailman_sync.py +++ b/mailman_sync.py @@ -13,7 +13,7 @@ import tempfile import requests -def config_list(mailman_bin: Path, mailing_list: str): +def config_list(mailman_bin: Path, mailing_list: str, dry_run: bool): config_changes = """ # TODO: set real_name, moderator, subject prefix, and reply-to address from_is_list = 1 @@ -38,13 +38,18 @@ forward_auto_discards = 0 # don't notify admin about discards with tempfile.NamedTemporaryFile("w", suffix=".py") as config_file: config_file.write(config_changes) config_file.flush() + + command = [ + mailman_bin / "config_list", + "--inputfile", + config_file.name, + mailing_list, + ] + if dry_run: + command.append("--checkonly") + output = subprocess.run( - [ - mailman_bin / "config_list", - "--inputfile", - config_file.name, - mailing_list, - ], + command, encoding="ascii", capture_output=True, check=True, @@ -97,7 +102,7 @@ def main(mailman_bin: Path, api: str, api_auth: str, list_suffix: str, dry_run: list_name = name + list_suffix if list_name in existing_lists: print(f"Configuring/syncing {list_name}...") - config_list(mailman_bin, list_name) + config_list(mailman_bin, list_name, dry_run) sync_members(mailman_bin, list_name, members, dry_run) else: print(f"Skipping {list_name}, as it does not exist in Mailman")