Created
September 4, 2014 00:06
-
-
Save kylestev/5163b613541776af8cd8 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
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