remove non members from a list
Hi all:
I need to remove all non members from a list. I know I can do it via Postorius, but it has to be done one at a time. (you can delete ALL suscribers but not all non members...)
Anyone has a python recipe to do this?
I've been searching and googling but I cannot find the way of doing it safely. And via DDBB there are more than one table involved and I'd rather not mess it all...
Thanks in advance
On 8/6/21 9:18 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
Hi all:
I need to remove all non members from a list. I know I can do it via Postorius, but it has to be done one at a time. (you can delete ALL suscribers but not all non members...)
Anyone has a python recipe to do this?
$ /opt/mailman/mm/bin/mailman shell -l list.example.com Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. The variable 'm' is the list.example.com mailing list
for nonmember in m.members.nonmembers: ... nonmember.unsubscribe() ... commit()
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 6/8/21 18:37, Mark Sapiro wrote:
On 8/6/21 9:18 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
Hi all:
I need to remove all non members from a list. I know I can do it via Postorius, but it has to be done one at a time. (you can delete ALL suscribers but not all non members...)
Anyone has a python recipe to do this?
$ /opt/mailman/mm/bin/mailman shell -l list.example.com Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. The variable 'm' is the list.example.com mailing list
for nonmember in m.members.nonmembers: ... nonmember.unsubscribe() ... commit()
Thanks a lot for the promt response, Mark.
It's not functioning. It says:
"AttributeError: 'MemberRoster' object has no attribute 'nonmembers'"
My system info is:
Mailman Core Version GNU Mailman 3.3.3 (Tom Sawyer) Mailman Core API Version 3.1 Mailman Core Python Version 3.7.9 (default, Nov 6 2020, 21:14:59) [Clang 8.0.1 (tags/RELEASE_801/final 366581)]
Postorius 1.3.4
On 8/6/21 9:48 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
It's not functioning. It says:
"AttributeError: 'MemberRoster' object has no attribute 'nonmembers'"
Sorry, that was a typo on my part. It should be
for nonmember in m.nonmembers.members: ... nonmember.unsubscribe() ... commit()
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 6/8/21 19:16, Mark Sapiro wrote:
On 8/6/21 9:48 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
It's not functioning. It says:
"AttributeError: 'MemberRoster' object has no attribute 'nonmembers'"
Sorry, that was a typo on my part. It should be
for nonmember in m.nonmembers.members: ... nonmember.unsubscribe() ... commit()
Thanks. Now it's no showing errors (and nothing at all) but apparently it does nothing. The non mebers of the list (the few that remains: I've been deleting one at a time from the web) aparently still are there..
Knowing the correct procedure will ease me to try tomorrow with a clean head.
Thanks a lot.
On 8/6/21 10:28 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
Thanks. Now it's no showing errors (and nothing at all) but apparently it does nothing. The non mebers of the list (the few that remains: I've been deleting one at a time from the web) aparently still are there..
Knowing the correct procedure will ease me to try tomorrow with a clean head.
It doesn't report anything, and if you don't commit() or exit with control-D, any changes will be rolled back.
What does
list(m.nonmembers.members)
show before doing the unsubscribe() and commit() and then what after?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 6/8/21 19:33, Mark Sapiro wrote:
On 8/6/21 10:28 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
Thanks. Now it's no showing errors (and nothing at all) but apparently it does nothing. The non mebers of the list (the few that remains: I've been deleting one at a time from the web) aparently still are there..
Knowing the correct procedure will ease me to try tomorrow with a clean head.
It doesn't report anything, and if you don't commit() or exit with control-D, any changes will be rolled back.
I think I did a typpo. (forgot to add "()" after the "commit" sentence).
And exit with quit() maybe not helps.
I've done it exactly as you wrote it and it worked like a charm.
Thank you very very much
What does
list(m.nonmembers.members)
show before doing the unsubscribe() and commit() and then what after?
participants (2)
-
Guillermo Hernandez (Oldno7)
-
Mark Sapiro