Created
May 17, 2018 02:44
-
-
Save brodygov/ca18a78034d15b038b5c9ca484bc9e35 to your computer and use it in GitHub Desktop.
Monitor a github user for public repos and alarm if any are found
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 json | |
import sys | |
import requests | |
def usage(): | |
print 'usage: repomonitor.py GITHUB_USER\n\nMonitor for public repos.' | |
def main(args): | |
if not args: | |
usage() | |
return 1 | |
username = args[0] | |
resp = requests.get('https://api.github.com/users/%s' % username) | |
data = resp.json() | |
if data['public_repos'] != 0: | |
print json.dumps(data, indent=2) | |
print 'PUBLIC REPOS IS NONZERO' | |
return 2 | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment