Skip to content

Instantly share code, notes, and snippets.

@mattias-lidman
Created January 26, 2015 17:25
Show Gist options
  • Save mattias-lidman/768c86badd7698bf0cbc to your computer and use it in GitHub Desktop.
Save mattias-lidman/768c86badd7698bf0cbc to your computer and use it in GitHub Desktop.
import itertools
# Get all OA4MP linked identities as a flat list
user_list = users.get_all_users() # Do this as a separate step because it's started timing out regularly
oauth_creds = itertools.chain.from_iterable([ user.credentials.get_all_credentials_of_type('oauth') for user in user_list if user.credentials.get_all_credentials_of_type('oauth')])
# Filter out bluewaters
bluewaters_creds = [ cred for cred in oauth_creds if cred['server'] == 'bluewaters.ncsa.illinois.edu' ]
# Update
for cred in bluewaters_creds: cred['server'] = 'oa4mp.ncsa.illinois.edu'; cred['id_index'] = "{0}_{1}".format(cred['oauth_username'], 'oa4mp.ncsa.illinois.edu'); cred.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment