]> err.no Git - dak/commitdiff
Improve performances of get_logins_from_ldap
authorLuca Falavigna <dktrkranz@debian.org>
Thu, 30 Aug 2012 15:13:33 +0000 (15:13 +0000)
committerLuca Falavigna <dktrkranz@debian.org>
Thu, 30 Aug 2012 15:13:33 +0000 (15:13 +0000)
Signed-off-by: Luca Falavigna <dktrkranz@debian.org>
dak/queue_report.py
daklib/utils.py

index a8f741026155e955a56b9876d1eafa9a3652fd26..a2079e81c10c869f301f5d0edc558ef6145d382e 100755 (executable)
@@ -47,7 +47,7 @@ from daklib.dbconn import DBConn, DBSource, has_new_comment, PolicyQueue, \
                           get_uid_from_fingerprint
 from daklib.policy import PolicyQueueUploadHandler
 from daklib.textutils import fix_maintainer
-from daklib.utils import get_login_from_ldap
+from daklib.utils import get_logins_from_ldap
 from daklib.dak_exceptions import *
 
 Cnf = None
@@ -416,6 +416,7 @@ def process_queue(queue, log, rrd_dir):
     max_source_len = 0
     max_version_len = 0
     max_arch_len = 0
+    logins = get_logins_from_ldap()
     for i in per_source_items:
         maintainer = {}
         maint=""
@@ -466,7 +467,8 @@ def process_queue(queue, log, rrd_dir):
                 sponsor_name = get_uid_from_fingerprint(fingerprint).name
                 sponsor_login = get_uid_from_fingerprint(fingerprint).uid
                 if '@' in sponsor_login:
-                    sponsor_login = get_login_from_ldap(fingerprint)
+                    if fingerprint in logins:
+                        sponsor_login = logins[fingerprint]
                 if (sponsor_name != maintainer["maintainername"] and
                   sponsor_name != changeby["changedbyname"] and
                   sponsor_login + '@debian.org' != maintainer["maintaineremail"] and
index f702db3fd74d44a93caa314310458fe1a4b16387..377d191348d51df9ecd62669cc1c3f244a655f19 100644 (file)
@@ -1411,7 +1411,7 @@ def gpg_get_key_addresses(fingerprint):
 
 ################################################################################
 
-def get_login_from_ldap(fingerprint):
+def get_logins_from_ldap(fingerprint='*'):
     """retrieve login from LDAP linked to a given fingerprint"""
 
     LDAPDn = Cnf['Import-LDAP-Fingerprints::LDAPDn']
@@ -1419,8 +1419,12 @@ def get_login_from_ldap(fingerprint):
     l = ldap.open(LDAPServer)
     l.simple_bind_s('','')
     Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL,
-                       '(keyfingerprint=%s)' % fingerprint, ['uid'])
-    return Attrs[0][1]['uid'][0]
+                       '(keyfingerprint=%s)' % fingerprint,
+                       ['uid', 'keyfingerprint'])
+    login = {}
+    for elem in Attrs:
+        login[elem[1]['keyFingerPrint'][0]] = elem[1]['uid'][0]
+    return login
 
 ################################################################################