From 6fe8664dcd0ce0e23f5f532d4bac4d96e961d667 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 19 May 2009 10:18:19 +0000 Subject: [PATCH] 2 listings --- plc-orphan-accounts.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/plc-orphan-accounts.py b/plc-orphan-accounts.py index fa8ee50..fc978ce 100755 --- a/plc-orphan-accounts.py +++ b/plc-orphan-accounts.py @@ -6,23 +6,29 @@ import time def get_orphans (): - return [p for p in GetPersons({'peer_id':None,'-SORT':'date_created'}) if not p['site_ids'] ] + return [p for p in GetPersons({'peer_id':None,'-SORT':'email'}) if not p['site_ids'] ] def list_person (margin,p): print margin,'%6d'%p['person_id'], time.asctime(time.gmtime(p['date_created'])), if not p['peer_id']: print 'LOCAL', else: print 'pr=',p['peer_id'], + if p['enabled']: print 'ENB', + else: print 'DIS', print p['email'] def get_related(email): return GetPersons ({'email':email,'~peer_id':None}) -def main (): - - orphans = get_orphans() - print GetPeerName(),' --- %d --- '%len(orphans),'orphan accounts' +def header (message): + print '--------------------' + print GetPeerName(), print time.asctime(time.gmtime()) - print '---' + print 'Listing orphan accounts and any similar remote' + print '--------------------' + +def main_orphans (): + orphans = get_orphans() + header ('Listing %d local accounts with no site - and similar remote accounts'%len(orphans)) index=1 for p in orphans: list_person ("%3d"%index,p) @@ -30,5 +36,19 @@ def main (): list_person("dup",related) index+=1 +def main_duplicates(): + + header ('Listing all duplicate accounts') + for local in GetPersons({'peer_id':None,'-SORT':'email'}): + remotes=GetPersons({'email':local['email'],'~peer_id':None}) + if remotes: + list_person('---',local) + for remote in remotes: + list_person('dup',remote) + +def main(): + main_orphans() + main_duplicates() + if __name__ == '__main__': main() -- 2.43.0