import json
from tasks import update_project, get_people_totals, get_org_totals

def update_projects():
    f = open('data/projects.json', 'rb')
    project_list = json.loads(f.read())
    f.close()
    details = []
    for project_url in project_list:
        try:
            pj_details = update_project(project_url)
        except IOError:
            return 'Github is throttling. Just gonna try again after limit is reset.'
        if pj_details:
            details.append(pj_details)
    f = open('data/project_details.json', 'wb')
    f.write(json.dumps(details, indent=4))
    f.close()
    f = open('data/people.json', 'wb')
    f.write(json.dumps(get_people_totals(details), indent=4))
    f.close()
    orgs = [d for d in details if d['owner']['type'] == 'Organization']
    f = open('data/organizations.json', 'wb')
    f.write(json.dumps(get_org_totals(orgs), indent=4))
    f.close()
    return 'Updated'

if __name__ == "__main__":
    update_projects()

@@ -5,16 +5,26 @@
 rt json%0A
+import os%0A
 from tas
@@ -87,51 +87,346 @@
 als%0A
-%0Adef update_projects():%0A    f = open('data/
+from boto.s3.connection import S3Connection%0Afrom boto.s3.key import Key%0A%0ABUCKET = os.environ%5B'S3_BUCKET'%5D%0AAWS_KEY = os.environ%5B'AWS_ACCESS_KEY'%5D%0AAWS_SECRET = os.environ%5B'AWS_SECRET_KEY'%5D%0A%0Adef update_projects():%0A    conn = S3Connection(AWS_KEY, AWS_SECRET)%0A    bucket = conn.get_bucket(BUCKET)%0A    pj_list = Key(bucket)%0A    pj_list.key = '
 proj
@@ -439,15 +439,8 @@
 son'
-, 'rb')
 %0A   
@@ -470,22 +470,46 @@
 ads(
-f.read
+pj_list.get_contents_as_string
 ())%0A    
 f.cl
@@ -500,25 +500,25 @@
 ring())%0A    
-f
+k
 .close()%0A   
@@ -814,403 +814,787 @@
     
-f = open('data/project_details.json', 'wb')%0A    f.write(json.dumps(details, indent=4))%0A    f.close()%0A    f = open('data/people.json', 'wb')%0A    f.write(json.dumps(get_people_totals(details), indent=4))%0A    f.close()%0A    orgs = %5Bd for d in details if d%5B'owner'%5D%5B'type'%5D == 'Organization'%5D%0A    f = open('data/organizations.json', 'wb')%0A    f.write(json.dumps(get_org_totals(orgs), indent=4))%0A    f
+pj_details = Key(bucket)%0A    pj_details.key = 'project_details.json'%0A    pj_details.set_contents_from_string(json.dumps(details))%0A    pj_details.set_metadata('Content-Type', 'application/json')%0A    pj_details.set_acl('public-read')%0A    pj_details.close()%0A    people_list = Key(bucket)%0A    people_list.key = 'people.json'%0A    people_list.set_contents_from_string(json.dumps(get_people_totals(details)))%0A    people_list.set_metadata('Content-Type', 'application/json')%0A    people_list.set_acl('public-read')%0A    people_list.close()%0A    org_list = Key(bucket)%0A    org_list.key = 'organizations.json'%0A    org_list.set_contents_from_string(json.dumps(get_org_totals(orgs)))%0A    org_list.set_metadata('Content-Type', 'application/json')%0A    org_list.set_acl('public-read')%0A    org_list
 .clo

Put together example of how one might write out the files to S3 instead of the local file system. Relates to #2