]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Changing output of summary
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 7 Jan 2021 08:16:12 +0000 (09:16 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 7 Jan 2021 08:16:12 +0000 (09:16 +0100)
lib/ldap_migration/__init__.py

index d607642071af3f4ae43219161dc0b9263a14ed9a..4c7c7adc0cbd17e3ba42d9d7b8d3c46f126d7656 100644 (file)
@@ -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__":