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'