On 2/21/22 03:28, Paul Paulchen wrote:
Thanks to this thread, I know how to find the lost souls in our mailman environment https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/thread/R...
um = getUtility(IUserManager) for usr in um.users: ... if len(list(usr.memberships.members)) > 0: ... continue ... adr = usr.addresses[0] ... print(f'Name: {adr.display_name}, Email: {adr.email}, Created: {usr.created_on}')
So I can see them now. Is there a technique, to clean them up? To get rid of them out of the system? I am not a python programmer, but I guess there is a way to use, instead of a single user, a list of users in the delete command of the mailman shell?
The replies by Guillermo and Andrew both point to a message/thread containing the same clean_users.py script. This script will do some of what you want, but maybe not all of it. It will delete Django users who have no corresponding Mailman user or have a corresponding Mailman user that has no role on any list, and optionally delete the Mailman user as well.
What it won't do is delete a Mailman user that has no role on any list if there is no corresponding Django user. For that you would want to add to the above fragment so it becomes:
>>> um = getUtility(IUserManager)
>>> for usr in um.users:
... if len(list(usr.memberships.members)) > 0:
... continue
... adr = usr.addresses[0]
... print(f'Name: {adr.display_name}, Email: {adr.email}, Created:
{usr.created_on}')
... um.delete_user(usr)
... print(' Deleted.)
...
>>> commit()
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan