adding some debugging but ultimately everything was fine
This commit is contained in:
Родитель
e873f0e31e
Коммит
981c387c8e
5
app.py
5
app.py
|
@ -70,7 +70,8 @@ def sync_team(client=None, owner=None, team_id=None, slug=None):
|
|||
directory_members = directory_group_members(group=directory_group)
|
||||
except Exception as e:
|
||||
directory_members = []
|
||||
print(e)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
||||
team_members = github_team_members(
|
||||
client=client, owner=owner, team_id=team_id, attribute=USER_SYNC_ATTRIBUTE
|
||||
)
|
||||
|
@ -108,7 +109,7 @@ def directory_group_members(group=None):
|
|||
group_members = [member for member in members]
|
||||
except Exception as e:
|
||||
group_members = []
|
||||
print(e)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
return group_members
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import traceback
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
from ldap3 import Server, Connection, ALL
|
||||
|
@ -73,18 +75,23 @@ class LDAPClient:
|
|||
try:
|
||||
member_dn = self.get_user_info(user=member)
|
||||
# pprint(member_dn)
|
||||
username = str(
|
||||
member_dn["attributes"][self.LDAP_USER_ATTRIBUTE][0]
|
||||
).casefold()
|
||||
email = str(
|
||||
member_dn["attributes"][self.LDAP_USER_MAIL_ATTRIBUTE][
|
||||
0
|
||||
]
|
||||
).casefold()
|
||||
user_info = {"username": username, "email": email}
|
||||
member_list.append(user_info)
|
||||
if (
|
||||
member_dn
|
||||
and member_dn["attributes"]
|
||||
and member_dn["attributes"][self.LDAP_USER_ATTRIBUTE]
|
||||
):
|
||||
username = str(
|
||||
member_dn["attributes"][self.LDAP_USER_ATTRIBUTE][0]
|
||||
).casefold()
|
||||
email = str(
|
||||
member_dn["attributes"][
|
||||
self.LDAP_USER_MAIL_ATTRIBUTE
|
||||
][0]
|
||||
).casefold()
|
||||
user_info = {"username": username, "email": email}
|
||||
member_list.append(user_info)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
return member_list
|
||||
|
||||
def get_user_info(self, user=None):
|
||||
|
@ -106,9 +113,10 @@ class LDAPClient:
|
|||
search_filter=self.LDAP_USER_FILTER.replace("{username}", user),
|
||||
attributes=["*"],
|
||||
)
|
||||
data = json.loads(self.conn.entries[0].entry_to_json())
|
||||
return data
|
||||
if len(self.conn.entries) > 0:
|
||||
data = json.loads(self.conn.entries[0].entry_to_json())
|
||||
return data
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
|
Загрузка…
Ссылка в новой задаче