Our organization has been been communicating through about a dozen mailing lists, running on mailman, with ~200 subscribers, for 15-odd years.
After Debian 10 LTS ran out, I had to upgrade our organisations Debian server, forcing me into mailman3.
I haven't managed, yet, to get the web interface running, so I need to do the most urgent tasks in the shell for now.
I have found out that, for example, to discard all held messages from the list "motor", I need to
sudo -u list mailman shell -l motor.our-server.de
and in the shell,
from mailman.app.moderator import handle_message rdb = IListRequest(m) for req in rdb.held_requests: ... if req.request_type == RequestType.held_message: ... handle_message(m, req.id, Action.discard) commit()
Now, obviously, I put these exact lines in a script, so I don't have to type it out every single time, and try to run it using
sudo -u list mailman shell -l testlist.our-server.de -r ./mm_discard_held.py
but that invariably gives me
Traceback (most recent call last): File "/usr/bin/mailman", line 33, in <module> sys.exit(load_entry_point('mailman==3.3.8', 'console_scripts', 'mailman')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/mailman/bin/mailman.py", line 69, in invoke return super().invoke(ctx) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/mailman/commands/cli_withlist.py", line 294, in shell r = call_name(dotted_name, m, *run_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/mailman/utilities/modules.py", line 69, in call_name named_callable = find_name(dotted_name) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/mailman/utilities/modules.py", line 52, in find_name module = import_module(module_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/__init__.py", line 121, in import_module raise TypeError(msg.format(name)) TypeError: the 'package' argument is required to perform a relative import for './mm_discard_held'
I've tried a PYTHONPATH=/root/bin , where mm_discard_held.py lives, as suggested.
I've tried moving it to the path where the mailman binary lives, as suggested.
I always get the same result.
What else can I do?
Thank you.