X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=getpersons.py;h=6525a1fb5abb8da7c9ba8f358dd552df7dcbd41f;hb=0ff00123853fd9880710be6399f532217f1f6989;hp=4ed24271e1493547a71351f04cbb94adff90c65b;hpb=0958d23852d17a8c3c8f8d4bf9e02c83587bf579;p=plcrt.git 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