Skip to content
Snippets Groups Projects
Verified Commit 24a64251 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Use tqdm for progress on interactive LDAP import

parent a10e1319
No related branches found
No related tags found
1 merge request!4Resolve "Mass import of users"
...@@ -9,6 +9,7 @@ from django.db.models import fields ...@@ -9,6 +9,7 @@ from django.db.models import fields
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from constance import config from constance import config
from tqdm import tqdm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -198,7 +199,7 @@ def ldap_sync_from_groups(group_infos): ...@@ -198,7 +199,7 @@ def ldap_sync_from_groups(group_infos):
# Resolve Group objects from LDAP group objects # Resolve Group objects from LDAP group objects
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 # Skip group if one of the name fields is missing
if config.LDAP_GROUP_SYNC_FIELD_SHORT_NAME not in ldap_group[1]: 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" % ( logger.error("LDAP group with DN %s does not have field %s" % (
...@@ -273,7 +274,7 @@ def mass_ldap_import(): ...@@ -273,7 +274,7 @@ def mass_ldap_import():
# Synchronise user data for all found users # Synchronise user data for all found users
ldap_users = backend.settings.USER_SEARCH.execute(connection, {"user": "*"}, escape=False) 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] uid = attrs[uid_field][0]
# Prepare an empty LDAPUser object with the target username # Prepare an empty LDAPUser object with the target username
......
...@@ -21,6 +21,7 @@ classifiers = [ ...@@ -21,6 +21,7 @@ classifiers = [
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.7"
django-ldapdb = "^1.4.0" django-ldapdb = "^1.4.0"
tqdm = "^4.44.1"
AlekSIS = { path = "../../.." } AlekSIS = { path = "../../.." }
[build-system] [build-system]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment