Add emailhost argument, set it in newlist and config_list

This commit is contained in:
Adam Goldsmith 2023-01-19 18:28:39 -05:00
parent 2b4d1acf52
commit 848c98c456

View File

@ -46,7 +46,7 @@ class ListManager:
for line in output.stdout.splitlines(): for line in output.stdout.splitlines():
print(f"[{script} {self.list_name}] {line}") print(f"[{script} {self.list_name}] {line}")
def newlist(self, urlhost: str, admin: str): def newlist(self, urlhost: str, emailhost: str, admin: str):
password = "".join(secrets.choice(PASSWORD_CHARS) for i in range(PASSWORD_LEN)) password = "".join(secrets.choice(PASSWORD_CHARS) for i in range(PASSWORD_LEN))
self._call_script( self._call_script(
@ -54,6 +54,7 @@ class ListManager:
[ [
"--quiet", "--quiet",
f"--urlhost={urlhost}", f"--urlhost={urlhost}",
f"--emailhost={emailhost}",
self.list_name, self.list_name,
admin, admin,
password, password,
@ -62,6 +63,7 @@ class ListManager:
def config_list( def config_list(
self, self,
emailhost: str,
real_name: str, real_name: str,
moderator: list[str], moderator: list[str],
subject_prefix: str, subject_prefix: str,
@ -71,6 +73,7 @@ class ListManager:
[ [
# have to modify mlist directly to allow removing suffix # have to modify mlist directly to allow removing suffix
"mlist.real_name = " + repr(real_name), "mlist.real_name = " + repr(real_name),
"host_name = " + repr(emailhost),
"moderator = " + repr(moderator), "moderator = " + repr(moderator),
"subject_prefix = " + repr(subject_prefix), "subject_prefix = " + repr(subject_prefix),
"from_is_list = 1", "from_is_list = 1",
@ -133,6 +136,7 @@ def main(
list_suffix: str, list_suffix: str,
dry_run: bool, dry_run: bool,
urlhost: str, urlhost: str,
emailhost: str,
admin: str, admin: str,
): ):
r = requests.get(api, headers={"Authorization": api_auth}) r = requests.get(api, headers={"Authorization": api_auth})
@ -155,10 +159,11 @@ def main(
print(f"Skipping non-existing list {list_name} in dry run mode") print(f"Skipping non-existing list {list_name} in dry run mode")
continue continue
else: else:
list_manager.newlist(urlhost, admin) list_manager.newlist(urlhost, emailhost, admin)
print(f"Configuring/syncing {list_name}...") print(f"Configuring/syncing {list_name}...")
list_manager.config_list( list_manager.config_list(
emailhost,
props["real_name"], props["real_name"],
props["moderator"], props["moderator"],
props["subject_prefix"], props["subject_prefix"],
@ -180,6 +185,9 @@ def parse_arguments():
argp.add_argument( argp.add_argument(
"--urlhost", help="Urlhost to use when creating new lists", required=True "--urlhost", help="Urlhost to use when creating new lists", required=True
) )
argp.add_argument(
"--emailhost", help="Emailhost to use when creating new lists", required=True
)
argp.add_argument( argp.add_argument(
"--admin", "--admin",
help="Admin email address to use when creating new lists", help="Admin email address to use when creating new lists",
@ -211,6 +219,7 @@ if __name__ == "__main__":
args.list_suffix, args.list_suffix,
args.dry_run, args.dry_run,
args.urlhost, args.urlhost,
args.emailhost,
args.admin, args.admin,
) )
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e: