Skip to content

Instantly share code, notes, and snippets.

@cnelson
Created March 14, 2017 14:43
Show Gist options
  • Select an option

  • Save cnelson/03e1cbaf0ce1472ef67fc765c3eb70e8 to your computer and use it in GitHub Desktop.

Select an option

Save cnelson/03e1cbaf0ce1472ef67fc765c3eb70e8 to your computer and use it in GitHub Desktop.

Revisions

  1. cnelson created this gist Mar 14, 2017.
    25 changes: 25 additions & 0 deletions dump-users.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/usr/bin/env python

    import re
    import subprocess
    import yaml

    import datetime

    since=datetime.datetime(2017, 2, 28, 0, 0, 0)

    # get one user toget the total number
    check = yaml.load(subprocess.check_output(['uaac', 'users', '--attributes', 'username', '--count', '1']))

    total = check['totalresults']

    data = yaml.load(subprocess.check_output(['uaac', 'users', '--attributes', 'username', '--attributes', 'meta.created', '--attributes', 'verified', '--count', str(total)]))

    assert data['itemsperpage'] == total

    is_email=r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
    for user in data['resources']:
    if re.match(is_email, user['username']) and user['meta.created'] >= since:
    user['created'] = user['meta.created']
    print("{username}\t{created}".format(**user))