zephyr_mirror: Fix handling of cross-realm Zephyr users.
(imported from commit c3739bcd383e73ef7f5347f0665e990a0d121a47)
This commit is contained in:
parent
eaf69717c1
commit
c783a52384
|
@ -79,10 +79,22 @@ humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu",
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
def to_humbug_username(zephyr_username):
|
def to_humbug_username(zephyr_username):
|
||||||
return zephyr_username.lower().split("@")[0] + "@mit.edu"
|
if "@" in zephyr_username:
|
||||||
|
(user, realm) = zephyr_username.split("@")
|
||||||
|
else:
|
||||||
|
(user, realm) = (zephyr_username, "mit.edu")
|
||||||
|
if realm.upper() == "ATHENA.MIT.EDU":
|
||||||
|
return user.lower() + "@mit.edu"
|
||||||
|
return user.lower() + "|" + realm + "@mit.edu"
|
||||||
|
|
||||||
def to_zephyr_username(humbug_username):
|
def to_zephyr_username(humbug_username):
|
||||||
return humbug_username.lower().split("@")[0] + "@ATHENA.MIT.EDU"
|
(user, realm) = humbug_username.split("@")
|
||||||
|
if "|" not in user:
|
||||||
|
return user.lower() + "@ATHENA.MIT.EDU"
|
||||||
|
match_user = re.match(r'([a-zA-Z0-9_]+)\|(.*)@mit\.edu', user)
|
||||||
|
if not match_user:
|
||||||
|
raise Exception("Could not parse Zephyr realm for cross-realm user %s" % (humbug_username,))
|
||||||
|
return match_user.group(1).lower() + "@" + match_user.group(2).upper()
|
||||||
|
|
||||||
def unwrap_lines(body):
|
def unwrap_lines(body):
|
||||||
# Split into paragraphs at two consecutive newlines, or a newline followed
|
# Split into paragraphs at two consecutive newlines, or a newline followed
|
||||||
|
@ -131,18 +143,12 @@ def fetch_fullname(username):
|
||||||
(datetime.datetime.now(), username)
|
(datetime.datetime.now(), username)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
domains = [
|
if "@" not in username:
|
||||||
("@CS.CMU.EDU", " (CMU)"),
|
return username
|
||||||
("@ANDREW.CMU.EDU", " (CMU)"),
|
(user, realm) = username.split("@")
|
||||||
("@IASTATE.EDU", " (IASTATE)"),
|
if realm.upper() == "MIT.EDU":
|
||||||
("@1TS.ORG", " (1TS)"),
|
return user
|
||||||
("@DEMENTIA.ORG", " (DEMENTIA)"),
|
return user.lower() + "@" + realm.upper()
|
||||||
("@MIT.EDU", ""),
|
|
||||||
]
|
|
||||||
for (domain, tag) in domains:
|
|
||||||
if username.upper().endswith(domain):
|
|
||||||
return username.split("@")[0] + tag
|
|
||||||
return username
|
|
||||||
|
|
||||||
fullnames = {}
|
fullnames = {}
|
||||||
def username_to_fullname(username):
|
def username_to_fullname(username):
|
||||||
|
|
Loading…
Reference in a new issue