From 24a642519ce98d893d9db3533b67317e30c0b2e2 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Sun, 29 Mar 2020 21:36:18 +0100 Subject: [PATCH] Use tqdm for progress on interactive LDAP import --- aleksis/apps/ldap/util/ldap_sync.py | 5 +++-- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aleksis/apps/ldap/util/ldap_sync.py b/aleksis/apps/ldap/util/ldap_sync.py index 977c615..5bbbd77 100644 --- a/aleksis/apps/ldap/util/ldap_sync.py +++ b/aleksis/apps/ldap/util/ldap_sync.py @@ -9,6 +9,7 @@ from django.db.models import fields from django.utils.translation import gettext as _ from constance import config +from tqdm import tqdm logger = logging.getLogger(__name__) @@ -198,7 +199,7 @@ def ldap_sync_from_groups(group_infos): # Resolve Group objects from LDAP group objects group_objects = [] - for ldap_group in group_infos: + for ldap_group in tqdm(group_infos): # Skip group if one of the name fields is missing if config.LDAP_GROUP_SYNC_FIELD_SHORT_NAME not in ldap_group[1]: logger.error("LDAP group with DN %s does not have field %s" % ( @@ -273,7 +274,7 @@ def mass_ldap_import(): # Synchronise user data for all found users ldap_users = backend.settings.USER_SEARCH.execute(connection, {"user": "*"}, escape=False) - for dn, attrs in ldap_users: + for dn, attrs in tqdm(ldap_users): uid = attrs[uid_field][0] # Prepare an empty LDAPUser object with the target username diff --git a/pyproject.toml b/pyproject.toml index 697302f..ea1fe41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.7" django-ldapdb = "^1.4.0" +tqdm = "^4.44.1" AlekSIS = { path = "../../.." } [build-system] -- GitLab