On 17/9/21 19:58, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
On 17/9/21 17:24, Mark Sapiro wrote:
On 9/17/21 6:18 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
On 16/9/21 16:40, Mark Sapiro wrote:
Are you asking what the equivalent MM 3 scripts would be?
More or less: I'm asking for a general direction here. I think I cannot use tthe "withlist" method as before, inside a python script, and I'm not sure how to do it.
You can run scripts via withlist in Mailman 3 similarly to Mailman 2. See https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/commands/do...
First, thanks for the prompt response, Mark.
Maybe I'm a little bit ofuscated, but I readed this doc many times when I was searching how to do it... but I cannot imagine how to do a shell or a python script, using the needed parameters, that sets hold on a member of a list.
I'll try to do some tests tomorrow.
I've followed the indications of a
mailman -C /usr/local/mailman3/var/etc/mailman.cfg shell --details
I've been trying to "translate" the python script that I made for mailman2 to new mailman3, but obviously, I'm missing something. It seems that mailman cannot locate the "module" needed.
The script is named "moderar.py":
*-*-*-*-*-*-*-*-*-* (begin of /usr/local/mailman3/moderar.py)
/usr/local/mailman3 # cat moderar.py #! /usr/local/bin/python3 # # script via withlist para moderar a pelo en mailman3 #
import os import sys
sys.path.insert(0, '/usr/local/mailman3') os.environ['PYTHONPATH'] = '/usr/local/mailman3' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' os.environ['MAILMAN_CONFIG_FILE'] = '/usr/local/mailman3/var/etc/mailman.cfg'
import mm_cfg
def moderar(mlist, member): if not mlist.Locked(): mlist.Lock() mlist.setMemberOption(member, mm_cfg.Moderate, True) mlist.Save() mlist.Unlock()
*-*-*-*-*-*-*-*-*-* (end of /usr/local/mailman3/moderar.py)
When I execute a
mailman withlist -r moderar -l list_to_use@mydomain.com address@moderate.com
The system returns:
Traceback (most recent call last): File "/usr/local/bin/mailman", line 11, in <module> load_entry_point('mailman==3.3.4', 'console_scripts', 'mailman')() File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/site-packages/mailman/bin/mailman.py", line 68, in invoke return super().invoke(ctx) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python3.7/site-packages/mailman/commands/cli_withlist.py", line 293, in shell r = call_name(dotted_name, m, *run_args) File "/usr/local/lib/python3.7/site-packages/mailman/utilities/modules.py", line 69, in call_name named_callable = find_name(dotted_name) File "/usr/local/lib/python3.7/site-packages/mailman/utilities/modules.py", line 52, in find_name module = import_module(module_path) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'moderar'
I've done a
ln -s /usr/local/mailman3/moderar.py /usr/local/lib/python3.7/site-packages/mailman/bin/moderar.py
But with the same result.
And I'm not sure if I'm doing well importing "mm_cfg" in the script.
My enviroment is open wide installation of mailman, python, etc. in a FreeBSD 12.2-RELEASE-p10
Mailman Core Version GNU Mailman 3.3.4 (Tom Sawyer) Mailman Core API Version 3.1 Mailman Core Python Version 3.7.9 (default, Nov 6 2020, 21:14:59) [Clang 8.0.1 (tags/RELEASE_801/final 366581)]
Postorius version: 1.3.5
If someone can give a hint it will be much appreciated.