--- /dev/null
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+
+"""Pour trouver dans quelle(s) ML(s) est quelqu'un et l'en virer.
+
+ À exécuter sur redisdead.
+ """
+
+from __future__ import print_function
+
+import socket
+if socket.gethostname() != "redisdead":
+ print("Not on redisdead, might not work")
+
+import sys
+
+sys.path.append("/var/lib/mailman/bin")
+
+import paths
+#from Mailman import mm_cfg
+from Mailman import MailList
+from Mailman import Utils
+
+def list_lists():
+ """Donne la liste des MLs"""
+ return [unicode(n) for n in Utils.list_names()]
+
+def list_members(ml):
+ """Donne la liste des membres de ``ml``.
+ Deals with fucking unicode problems."""
+ ml = MailList.MailList(ml, lock=False)
+ rmembers = ml.getRegularMemberKeys()
+ dmembers = ml.getDigestMemberKeys()
+ l = rmembers + dmembers
+ l = [s if isinstance(s, unicode) else s.decode("utf-8") for s in l]
+ return l
+
+def get_all():
+ """Retourne un dico nom_de_ml -> membres"""
+ return {n: list_members(n) for n in list_lists()}
+
+def get_mls_from_mail(mail, all=None):
+ """Retourne la liste des mls auxquelles est abonné ``mail``.
+ Calcule le dico ``all`` si on ne lui donne pas."""
+ if all == None:
+ all = get_all()
+ return [n for (n, members) in all.iteritems() if mail in members]
+
+def exterminate(mail, ml):
+ """Désabonne ``mail`` de ``ml``.
+ Pas de notification à mail, mais à l'admin."""
+ l = MailList.MailList(ml.encode(), lock=True)
+ l.DeleteMember(mail.encode(), admin_notif="prout", userack=False)
+ l.Save()
+ l.Unlock()
+
+if __name__ == "__main__":
+ bad_guy = sys.argv[1].decode("utf-8").lower()
+ mls = get_mls_from_mail(bad_guy)
+ mls.sort()
+ if mls:
+ print("Exterminating %s from %s" % (bad_guy, ", ".join(mls)))
+ answer = raw_input("[y/n] ?")
+ if answer.lower() == "y":
+ for n in mls:
+ exterminate(bad_guy, n)
+ else:
+ print("No mailing list found")