Skip to content

Instantly share code, notes, and snippets.

@kylestev
Created September 4, 2014 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylestev/5163b613541776af8cd8 to your computer and use it in GitHub Desktop.
Save kylestev/5163b613541776af8cd8 to your computer and use it in GitHub Desktop.
import json
import requests
import sys
COMPANY_TABLE_ID = 'company_table'
URL_STACKALYTICS = 'http://stackalytics.com/api/1.0/stats'
URL_SA_IRONIC_METRICS = '{}/{}?module={}&metric={}'.format(
URL_STACKALYTICS, '{}', 'ironic-group', '{}')
def get_json(url):
res = requests.get(url)
if not 200 <= res.status_code < 300:
return None
return res.json()
def main(metric):
resp = get_json(URL_SA_IRONIC_METRICS.format('companies', metric))
if resp is None:
print 'resp was None!'
return
for company in resp['stats'][:5]:
print '%(name)s: %(metric)s' % (company)
if __name__ == '__main__':
metric = sys.argv[1] if len(sys.argv) == 2 else 'commits'
main(metric)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment