try to add the reverse-lookup hostname as well to make the rtdemo work
[plcrt.git] / getpersons.py
1 #!/bin/env plcsh
2
3 import sys
4
5 p = GetPersons(None, ['email', 'first_name', 'last_name', 'roles', 'site_ids'])
6
7 admins = filter(lambda x: sys.argv[1] in x['roles'], p)
8
9 for a in admins:
10     if 'site_ids' in a:
11         s = GetSites(a['site_ids'], ['name'])
12         if len(s) > 0:
13             organization = s[0]['name']
14         else:
15             organization = "Unknown"
16     else:
17         organization = "Unknown"
18
19     a['name'] = organization
20     print "%(email)s,%(first_name)s %(last_name)s,%(name)s" % a