-
Notifications
You must be signed in to change notification settings - Fork 2
/
fas-hungary.py
executable file
·32 lines (24 loc) · 987 Bytes
/
fas-hungary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import getpass
from fedora.client.fas2 import AccountSystem
import codecs
def calc_list():
'''Generate data'''
output = []
people_list = []
flag = 0
group_name = 'cla_done'
username = 'FASusername'
password = 'FASpassword'
fas = AccountSystem(username=username, password=password)
print 'Generating data file. Wait...'
data = fas.people_by_key(key='username', search=u'*', fields=['human_name', 'username', 'email', 'status', 'country_code'])
output_file = codecs.open('/tmp/hungary.txt', encoding='utf-8', mode='w+')
for item in data.values():
if str(item['country_code']) == 'HU' and item['status'] == 'active':
output_data = item['human_name'] + " " + item['username'] + " " + item['email'] + " " + str(item['country_code']) + " " + item['status'] + "\n"
output_file.write(output_data)
output_file.close()
print 'file successfully generated'
if __name__ == "__main__":
calc_list()