Hello Mailman-users.
I was hoping someone more experienced than myself would be able to help me with an issue I am currently experiencing.
I have created a function to add moderators which works great, but I have also been trying to remove moderators as another function, but I am running into some issues.
When I use the mailman shell based upon the documentation, it works great: https://docs.mailman3.org/projects/mailmanclient/en/latest/src/mailmanclient... everything works as expected.
However, if I try and bring that in as a function that can be used with mailman withlist, I am consistently getting errors, and being that I am not very experienced in python, it has me scratching my head to say the least.
from mailmanclient import Client from mailman.interfaces.member import MemberRole, AlreadySubscribedError from mailman.testing.helpers import subscribe
addresses = ['test1@example.com', 'test2@example.com', 'test3@example.com']
client = Client('http://localhost:8001/3.1', 'restadmin', 'restpass')
def set_owners(mlist):
for email_addr in addresses:
try:
member = subscribe(mlist, '', email=email_addr, role=MemberRole.owner )
print (member)
except AlreadySubscribedError as err:
print (err)
def remove(mlist): my_list = client.get_list(mlist) # print(my_list.fqdn_listname) # for email_addr in addresses: # my_list.remove_owner(email_addr)
The errors I am getting are:
./bin/mailman withlist -r set_owners.remove -l it-test-b@lists.rhoworld.com Traceback (most recent call last): File "./bin/mailman", line 8, in <module> sys.exit(main()) File "/opt/mailman3/lib/python3.6/site-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/opt/mailman3/lib/python3.6/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/opt/mailman3/lib/python3.6/site-packages/mailman/bin/mailman.py", line 68, in invoke return super().invoke(ctx) File "/opt/mailman3/lib/python3.6/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/mailman3/lib/python3.6/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/opt/mailman3/lib/python3.6/site-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/opt/mailman3/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/opt/mailman3/lib/python3.6/site-packages/mailman/commands/cli_withlist.py", line 293, in shell r = call_name(dotted_name, m, *run_args) File "/opt/mailman3/lib/python3.6/site-packages/mailman/utilities/modules.py", line 70, in call_name return named_callable(*args, **kws) File "/opt/mailman3/bin/set_owners.py", line 24, in remove my_list = client.get_list(mlist) File "/opt/mailman3/lib/python3.6/site-packages/mailmanclient/client.py", line 347, in get_list 'lists/{0}'.format(fqdn_listname)) File "/opt/mailman3/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 112, in call error_msg, response, None) urllib.error.HTTPError: HTTP Error 404: 404 Not Found
So, I am wondering, is it possible to do something like this or am I completely misunderstanding the documentation, and why do I get a 404 here, when in the shell everything works as expected. I know I must be missing something, but cannot for the life of me figure out what that is. Any help would be greatly appreciated.
Thanks,
Sean