Skip to content

Instantly share code, notes, and snippets.

@brodygov
Created May 17, 2018 02:44
Show Gist options
  • Save brodygov/ca18a78034d15b038b5c9ca484bc9e35 to your computer and use it in GitHub Desktop.
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
#!/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