#186 Add script to get e-mails from FAS usernames
Merged 4 years ago by alciregi. Opened 4 years ago by ankursinha.

@@ -0,0 +1,34 @@ 

+ #!/usr/bin/env python3

+ """

+ Get e-mail addresses for provided FAS usernames.

+ 

+ File: get_emails_from_fas.py

+ 

+ Copyright 2020 Ankur Sinha

+ Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>

+ """

+ 

+ 

+ from fedora.client.fas2 import AccountSystem

+ 

+ # Read FAS usernames from a file

+ usernames = open('usernames.txt').read().splitlines()

+ emails = []

+ 

+ your_fas_username = "something"

+ your_fas_password = "something"

+ 

+ # Get an account system object

+ fas = AccountSystem(username=your_fas_username, password=your_fas_password)

+ 

+ for username in usernames:

+     print("Fetching e-mail for {}".format(username))

+     r = fas.people_by_key(key="username", search=username, fields=["email"])

+     print("Found: {}".format(r[username].email))

+     emails.append(r[username].email)

+ 

+ with open("emails.txt", 'w') as f:

+     for email in emails:

+         print(email, file=f)

+ 

+ print("List printed to emails.txt")

no initial comment

Pull-Request has been merged by alciregi

4 years ago
Metadata