Created
February 3, 2016 14:20
-
-
Save hoov/a8d5fdf81211168d18ee to your computer and use it in GitHub Desktop.
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
#!/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: | |
from pprint import pprint | |
pprint(user) | |
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