Created
February 3, 2016 15:25
-
-
Save hoov/68cc6c9c3fa0e3e7aaed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import argparse | |
import sys | |
import requests | |
def trace(s, *n): | |
print(str(s) % n) | |
def github_or_die(url, auth_token): | |
headers = dict(Authorization="token %s" % auth_token) | |
resp = requests.get(url, headers=headers) | |
try: | |
resp.raise_for_status() | |
except requests.exceptions.HTTPError as e: | |
trace("Error talking to GitHub: %r", e.message) | |
sys.exit(1) | |
return resp.json() | |
def find_bad_people(auth_token): | |
bad_users = github_or_die("https://api.github.com/orgs/InsightSquared/members?filter=2fa_disabled", auth_token) | |
for user in bad_users: | |
user_info = github_or_die("https://api.github.com/users/%s" % user["login"], auth_token) | |
name = user_info["name"] | |
login = user_info["login"] | |
email = user_info["email"] | |
trace("%s (%s) <%s>", name, login, email) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("auth_token") | |
args = parser.parse_args() | |
find_bad_people(args.auth_token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment