Fix broken parsing of DNS response.

(imported from commit 3a627d45bc313bf244dc699a59df9423c849bc35)
This commit is contained in:
Luke Faraone 2013-08-13 10:21:24 -07:00
parent ad10cecdd7
commit 3129b6374d
1 changed files with 3 additions and 1 deletions

View File

@ -168,11 +168,13 @@ def compute_mit_user_fullname(email):
answer = DNS.dnslookup(
"%s.passwd.ns.athena.mit.edu" % (match_user.group(1),),
DNS.Type.TXT)
hesiod_name = answer[0].split(':')[4].split(',')[0].strip()
hesiod_name = answer[0][0].split(':')[4].split(',')[0].strip()
if hesiod_name != "":
return hesiod_name
elif match_user:
return match_user.group(1).lower() + "@" + match_user.group(2).upper()[1:]
except DNS.Base.ServerError:
pass
except:
print ("Error getting fullname for %s:" % (email,))
traceback.print_exc()