Last active
July 11, 2017 20:04
-
-
Save brucehoff/b94906919f79647462b411ff730c26fc to your computer and use it in GitHub Desktop.
Python script to export email addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This script downloads name and email information for a Synapse Team | |
# | |
# usage: python exportEmail.py -u <synapse-username> -p <synapse-password> -t <team-name> -f <output-filepath> | |
# If <team-name> includes spaces then enclose the name with quotes | |
# | |
# To install the Synapse Python client see: http://docs.synapse.org/python/#installation | |
# | |
import synapseclient | |
import argparse | |
import os | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-u","--synapseUser", required=True, | |
help="Synapse user name") | |
parser.add_argument("-p","--synapsePassword", required=True, | |
help="Synapse password") | |
parser.add_argument("-t", "--teamName", required=True, help="team name. Use quotes if name has spaces") | |
parser.add_argument("-f", "--filePath", required=True, help="output file path") | |
args = parser.parse_args() | |
syn = synapseclient.Synapse() | |
syn = synapseclient.login(args.synapseUser, args.synapsePassword,rememberMe=False) | |
outfilehandle = open(args.filePath, 'w') | |
try: | |
outfilehandle.write("First\tLast\tEmail\n") | |
for teamMember in syn.getTeamMembers(syn.getTeam(args.teamName)): | |
member = teamMember.member | |
outfilehandle.write((member.firstName+"\t"+member.lastName+"\t"+member.userName+"@synapse.org\n").encode('utf-8')) | |
finally: | |
outfilehandle.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment