From: Dan Scott Date: Fri, 7 Oct 2011 17:16:09 +0000 (-0400) Subject: LDAP patron load: handle more errors more gracefully X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=031e323b76bea365bf711057adcf4fd2ee5ee56f;p=contrib%2FConifer.git LDAP patron load: handle more errors more gracefully It's possible for users in LDAP to not have email; instead of absolutely dying, just warn and move on to the next user. Signed-off-by: Dan Scott --- diff --git a/tools/patron-load/ldap_osrf_sync b/tools/patron-load/ldap_osrf_sync index 2bab8b6bd2..8b2626d36d 100755 --- a/tools/patron-load/ldap_osrf_sync +++ b/tools/patron-load/ldap_osrf_sync @@ -82,13 +82,13 @@ class User: if 'mail' not in self.ldap_atts: print >> sys.stderr, 'mail not found for %s' % self.cname - return None + # return None # Strip leading/ending whitespace; LDAP data can be dirty # Using email for username deliberately here - self.usrname = self._simple_map('mail').lower() - self.email = self._simple_map('mail').lower() + self.usrname = (self._simple_map('mail') or '').lower() + self.email = (self._simple_map('mail') or '').lower() self.family_name = self._simple_map('sn') self.ident_type, self.ident_value = self.get_identity() self.home_ou = self.get_home_ou() @@ -165,6 +165,7 @@ class User: 'faculty': 11, 'staff': 15, 'proxy': None, + 'retired': None, 'affiliate': 15 } @@ -173,6 +174,7 @@ class User: else: print >> sys.stderr, "Affiliation '%s' not mapped to a profile " \ "for user %s" % (affiliation, self.usrname) + return None def get_home_ou(self): """ @@ -308,6 +310,9 @@ def find_ldap_users(con, ldap_filter, attributes, auth): if res: update_ldap_barcode(con, user) if ARGS.push_barcode: + if user.barcode: + continue + try: uid = find_evergreen_user(auth, user) except AttributeError: @@ -399,6 +404,9 @@ def create_evergreen_user(auth, user): print >> sys.stderr, "No profile set for %s" % user.usrname return + if user.barcode is not None: + return + found = find_evergreen_user(auth, user) if found: print("Found: %s" % user.usrname)