X-Git-Url: http://git.onelab.eu/?p=plcrt.git;a=blobdiff_plain;f=getpersons.py;fp=getpersons.py;h=6525a1fb5abb8da7c9ba8f358dd552df7dcbd41f;hp=4ed24271e1493547a71351f04cbb94adff90c65b;hb=01a0036064141b1031fe3d06162eec10d81aa135;hpb=fe7dfc2e49c185a4325af790032efad454b4d226 diff --git a/getpersons.py b/getpersons.py index 4ed2427..6525a1f 100644 --- a/getpersons.py +++ b/getpersons.py @@ -7,10 +7,14 @@ p = GetPersons(None, ['email', 'first_name', 'last_name', 'roles', 'site_ids']) admins = filter(lambda x: sys.argv[1] in x['roles'], p) for a in admins: - s = GetSites(a['site_ids'], ['name']) - if len(s) > 0: - organization = s[0]['name'] - else: - organization = "Unknown" - a['name'] = organization - print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a + if 'site_ids' in a: + s = GetSites(a['site_ids'], ['name']) + if len(s) > 0: + organization = s[0]['name'] + else: + organization = "Unknown" + else: + organization = "Unknown" + + a['name'] = organization + print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a