From: Frank Brehm Date: Thu, 7 Jan 2021 08:16:12 +0000 (+0100) Subject: Changing output of summary X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=aca361905714a93d2b2b4d7f9845f60bb955d11e;p=pixelpark%2Fldap-migration.git Changing output of summary --- diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index d607642..4c7c7ad 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -45,7 +45,7 @@ from fb_tools.collections import CIStringSet, CIDict from .config import LDAPMigrationConfiguration -__version__ = '0.9.7' +__version__ = '0.9.8' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -1328,15 +1328,7 @@ class LDAPMigrationApplication(BaseApplication): msg += "\n" + '\n'.join(map(lambda x: ' * {!r}'.format(x), self.group_entries.keys())) LOG.info(msg) - print() - total = self.count_unchanged + self.count_added + self.count_modified + count_groups - msg = ( - "Performed all entries: {to} total, {ad} added, {mo} modified, " - "{un} unchanged, {g} ignored groups.").format( - to=total, ad=self.count_added, mo=self.count_modified, - un=self.count_unchanged, g=count_groups) - LOG.info(msg) - + LOG.info("Performed all entries.") time.sleep(3) return True @@ -1752,6 +1744,52 @@ class LDAPMigrationApplication(BaseApplication): return False + # ------------------------------------------------------------------------- + def detailled_summary(self): + + if self.verbose > 1: + print() + print(self.colored('Migrated items:', 'GREEN')) + print(self.colored('###############', 'GREEN')) + for key in self.migrated_entries: + print(self.colored(' * {!r}'.format(key), 'GREEN')) + if len(self.src_items_not_found): + print() + print(self.colored('Not migrated items:', 'AQUA')) + print(self.colored('###################', 'AQUA')) + for dn in self.src_items_not_found: + print(self.colored(' * {!r}'.format(dn), 'AQUA')) + if self.verbose: + if len(self.unknown_attributetypes): + print() + print(self.colored('Unknown and not migrated Attribute Types:', 'AQUA')) + print(self.colored('#########################################', 'AQUA')) + for at in self.unknown_attributetypes: + print(self.colored(' * {!r}'.format(at), 'AQUA')) + if len(self.unknown_objectclasses): + print() + print(self.colored('Unknown and not migrated Object Classes:', 'AQUA')) + print(self.colored('########################################', 'AQUA')) + for oc in self.unknown_objectclasses: + print(self.colored(' * {!r}'.format(oc), 'AQUA')) + + # ------------------------------------------------------------------------- + def summary(self): + + count_groups = 0 + if self.group_entries: + count_groups = len(self.group_entries) + + print() + total = self.count_unchanged + self.count_added + self.count_modified + count_groups + msg = ( + "Performed all entries: {to} total, {ad} added, {mo} modified, " + "{un} unchanged, {g} ignored groups.").format( + to=total, ad=self.count_added, mo=self.count_modified, + un=self.count_unchanged, g=count_groups) + LOG.info(msg) + print() + # ------------------------------------------------------------------------- def _run(self): @@ -1765,40 +1803,16 @@ class LDAPMigrationApplication(BaseApplication): self.get_all_dns() self.get_structural_dns() self.migrate_entries() - if self.verbose > 1: - print() - print(self.colored('Migrated items:', 'GREEN')) - print(self.colored('###############', 'GREEN')) - for key in self.migrated_entries: - print(self.colored(' * {!r}'.format(key), 'GREEN')) - if len(self.src_items_not_found): - print() - print(self.colored('Not migrated items:', 'AQUA')) - print(self.colored('###################', 'AQUA')) - for dn in self.src_items_not_found: - print(self.colored(' * {!r}'.format(dn), 'AQUA')) - if self.verbose: - if len(self.unknown_attributetypes): - print() - print(self.colored('Unknown and not migrated Attribute Types:', 'AQUA')) - print(self.colored('#########################################', 'AQUA')) - for at in self.unknown_attributetypes: - print(self.colored(' * {!r}'.format(at), 'AQUA')) - if len(self.unknown_objectclasses): - print() - print(self.colored('Unknown and not migrated Object Classes:', 'AQUA')) - print(self.colored('########################################', 'AQUA')) - for oc in self.unknown_objectclasses: - print(self.colored(' * {!r}'.format(oc), 'AQUA')) + self.detailled_summary() finally: self.disconnect() + self.summary() LOG.info("Ending {a!r}.".format( a=self.appname, v=self.version)) - # ============================================================================= if __name__ == "__main__":