Sorry for my ignorance. May I know what should be imported before using mailman shell within Python?
$ python3.6 Python 3.6.6 (default, Aug 13 2018, 18:24:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license" for more information.
command = cli('mailman.commands.cli_withlist.shell') Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'cli' is not defined
Link to documentation: https://mailman.readthedocs.io/en/latest/src/mailman/commands/docs/shell.htm...
On 1/2/19 7:12 PM, Alan So wrote:
Sorry for my ignorance. May I know what should be imported before using mailman shell within Python?
$ python3.6 Python 3.6.6 (default, Aug 13 2018, 18:24:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license" for more information.
command = cli('mailman.commands.cli_withlist.shell') Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'cli' is not defined
Link to documentation: https://mailman.readthedocs.io/en/latest/src/mailman/commands/docs/shell.htm...
That's too complicated. Just run
mailman shell
as a command. If you want to operate on a single list, run
mailman shell -l <list_id>
Also see
mailman shell --details
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Thanks. I tried before already. I have defined var_dir but it does not search showme.py there. That's why I want to run it within Python so that I can change sys.path.
/etc/mailman.cfg: var_dir: /usr/local/share/mailman-suite/mailman-suite_project/var
$ cat /usr/local/share/mailman-suite/mailman-suite_project/var/showme.py def showme(mlist): print("The list's name is", mlist.fqdn_listname)
def displayname(mlist): print("The list's display name is", mlist.display_name)
def changeme(mlist, display_name): mlist.display_name = display_name
$ mailman shell -l test@test.myorg.com --run showme.displayname Traceback (most recent call last): File "/usr/local/bin/mailman", line 9, in <module> load_entry_point('mailman==3.2.0', 'console_scripts', 'mailman')() File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.6/site-packages/mailman/bin/mailman.py", line 69, in invoke return super().invoke(ctx) File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/usr/local/lib64/python3.6/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python3.6/site-packages/mailman/commands/cli_withlist.py", line 293, in shell r = call_name(dotted_name, m, *run_args) File "/usr/local/lib/python3.6/site-packages/mailman/utilities/modules.py", line 69, in call_name named_callable = find_name(dotted_name) File "/usr/local/lib/python3.6/site-packages/mailman/utilities/modules.py", line 52, in find_name module = import_module(module_path) File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'showme'
On 1/2/19 8:43 PM, Alan So wrote:
Thanks. I tried before already. I have defined var_dir but it does not search showme.py there.
Try putting the scripts in Mailman's bin directory or whatever directory the 'mailman' command is in.
$ mailman shell -l test@test.myorg.com --run showme.displayname
Or run
PYTHONPATH=/usr/local/share/mailman-suite/mailman-suite_project/var/
mailman shell -l test@test.myorg.com --run showme.displayname
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Thanks for the advice. It works.
Actually I am looking for ways to remove non-members since it seems that we cannot do so through the mailman client. Any pointer to related documentation? The closest one seems to be https://mailman.readthedocs.io/en/latest/src/mailman/commands/docs/members.h... but it only talk about adding members.
On 1/2/19 10:45 PM, Alan So wrote:
Actually I am looking for ways to remove non-members since it seems that we cannot do so through the mailman client. Any pointer to related documentation? The closest one seems to be https://mailman.readthedocs.io/en/latest/src/mailman/commands/docs/members.h... but it only talk about adding members.
See <https://mailman.readthedocs.io/en/latest/src/mailman/model/docs/subscriptions.html>
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On Wed, Jan 2, 2019, at 10:45 PM, Alan So wrote:
Thanks for the advice. It works.
Actually I am looking for ways to remove non-members since it seems that we cannot do so through the mailman client. Any pointer to related documentation? The closest one seems to be https://mailman.readthedocs.io/en/latest/src/mailman/commands/docs/members.h... but it only talk about adding members.
You can remove non-members using Mailman Client, it is less documented though.
https://mailmanclient.readthedocs.io/en/latest/src/mailmanclient/docs/apiref...
MailingList.remove_role('nonmember', 'email_address@example.com')
This will remove the nonmember you want.
Mailman-users mailing list -- mailman-users@mailman3.org To unsubscribe send an email to mailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
-- thanks, Abhilash Raj (maxking)
participants (3)
-
Abhilash Raj
-
Alan So
-
Mark Sapiro