Dear Stephen,
this was nice but is not working for me.
I edited a file with name set_user_prefs (without .py) (to preset up user
preference in the whole system):
def set_members_prefs():
from zope.component import getUtility
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.member import DeliveryMode, DeliveryStatus
hide_address = True
delivery_status = DeliveryStatus.enabled
lm = getUtility(IListManager)
for mlist in lm.mailing_lists:
for member in mlist.members.members:
prefs = member.preferences
prefs.acknowledge_posts = True
prefs.hide_address = hide_address
prefs.preferred_language = 'de'
prefs.receive_list_copy = True
prefs.receive_own_postings = True
prefs.delivery_mode = DeliveryMode.regular
prefs.delivery_status = delivery_status
print(f"Updated {member.address.email} in list {mlist.fqdn_listname}")
I went to my (venv) and typed
(in /opt/mailman)
$/opt/mailman: mailman withlist -r /opt/mailman/set_members_prefs
or short
mailman withlist -r set_members_prefs
and got
(venv) mailman@cloud:~$ mailman withlist -r /opt/mailman/set_members_prefs
Traceback (most recent call last):
File "/opt/mailman/venv/bin/mailman", line 8, in <module>
sys.exit(main())
File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line
1161, in __call__
return self.main(*args, **kwargs)
File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line
1082, in main
rv = self.invoke(ctx)
File "/opt/mailman/venv/lib/python3.9/site-packages/mailman/bin/mailman.py",
line 69, in invoke
return super().invoke(ctx)
File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line
1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line
1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 788,
in invoke
return __callback(*args, **kwargs)
File "/opt/mailman/venv/lib/python3.9/site-packages/click/decorators.py",
line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File
"/opt/mailman/venv/lib/python3.9/site-packages/mailman/commands/cli_withlist.py",
line 280, in shell
r = call_name(dotted_name, *run_args)
File
"/opt/mailman/venv/lib/python3.9/site-packages/mailman/utilities/modules.py",
line 69, in call_name
named_callable = find_name(dotted_name)
File
"/opt/mailman/venv/lib/python3.9/site-packages/mailman/utilities/modules.py",
line 52, in find_name
module = import_module(module_path)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named '/opt/mailman/set_members_prefs'
Perhaps you know, what I did wrong, and can help with a working solution. I
guess, it can help many users, too.
_______________________________________________
Mailman-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
Archived at:
https://lists.mailman3.org/archives/list/[email protected]/message/BCPOG53LQBHNF4ZNAUKE62T4NFDD7LOU/
This message sent to [email protected]