Hi again folks. I have hundreds of lists to convert from MM2.1 to MM3, and intend to write a Python program do this this rather than running commands in mailman shell (and rather than running 'command()' functions in mailman shell, if possible).
However, when I write a simple Python program to run the types of commands found in the Mailman docs, such as these <https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/commands/docs/shell.html>, I get errors. This is a venv installation, following these instructions <https://docs.mailman3.org/en/latest/install/virtualenv.html>. The Mailman3 installation is working fine and I have a handful of lists in production that I set up manually.
Here's a very simple program, import-try1.py, just to create a list: #!/opt/mailman/venv/bin/python3
from mailman.app.lifecycle import create_list l = create_list('testlist2@lists.aaabbb.org')
Here's the output I get (yes, the domain exists and already has lists - I'm putting aaabbb instead of the actual domain name):
./import-try1.py Traceback (most recent call last): File "/opt/mailman/./import-try1.py", line 4, in <module> l = create_list('testlist2@lists.aaabbb.org') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/mailman/venv/lib/python3.12/site-packages/mailman/app/lifecycle.py", line 74, in create_list getUtility(IEmailValidator).validate(fqdn_listname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/mailman/venv/lib/python3.12/site-packages/zope/component/_api.py", line 180, in getUtility raise ComponentLookupError(interface, name) zope.interface.interfaces.ComponentLookupError: (<InterfaceClass mailman.interfaces.address.IEmailValidator>, '')
I get different errors with other sets of commands. The same commands work
fine from mailman shell
, i.e.,
(venv) mailman@mail:~$ mailman shell Welcome to the GNU Mailman3 shell on aaabbb.org
from mailman.app.lifecycle import create_list l = create_list('testlist2@lists.aaabbb.org')
Output from mailman info, with the passwords omitted:
GNU Mailman 3.3.9 (Tom Sawyer) Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] config file: /etc/mailman3/mailman.cfg db url: postgresql://mailman:secretaaabbb@localhost/mailman devmode: DISABLED REST root url: http://localhost:8001/3.1/ REST credentials: restadmin:reallysecretaaabbb
I suspect I just need to either change the interpreter (1st line of my program), or find the correct 'import' lines (I've tried numerous variations; the above is the simplest example). Help will be appreciated! Greg