Example #1
0
 def get(self):
     logging.debug("#######> DS: Maint: LoadProjects")
     ch = Change.all()
     
     seen = {}
     db.delete(Project.all())
     dev_p = CustomRomDevices().getDevices()['projects']
     self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
     for c in ch:
         if c.project == 'KANG': continue
         if c.project in seen: continue
         
         p_type = project_type(c.project)
         self.response.out.write(c.project+"\n")
         seen[c.project] = 1
         project = Project(
                     branch=c.branch,
                     type=p_type,
                     project=c.project
                 )
         project.put()
     
     #memcache.flush_all()
     memcache_delete_multi(['filtered', 'merge-builds', 'device-projects'])
     return
Example #2
0
    def _update_changes(self, changes=[], known_ids=[]):
        skipped = 0
        updates = False
        branches = {}
        cl_projects = Projects()
        cl_last_chg = LastChanges()
        
        for c in changes:
            if c['id']['id'] in known_ids:
                skipped += 1
                continue

            updates = True
            change = Change(id=c['id']['id'],
                    branch=c['branch'],
                    project=c['project']['key']['name'].split("/")[1],
                    subject=c['subject'],
                    last_updated=c['lastUpdatedOn']
                    )
            change.put()
            
            # append change to memcache (last changes)
            known_ids.append(change.id)
            memcache.set('known_ids', known_ids)
            cl_last_chg.append(change)
            branches[change.branch] = 1
            
            # append new project
            p_type = project_type(change.project)
            if not change.project in cl_projects.list(change.branch, p_type):
                project = Project(
                                branch  = change.branch,
                                type    = p_type,
                                project = change.project
                            )
                project.put()
                cl_projects.append(project)
        
        if updates:
            for b in branches:
                cl_last_chg.sort(b)
            
            logging.debug("###> MemCache: Flush after new changes")
            # flush all memcache on new changes for people to see them immediately
            memcache_delete_multi(['filtered', 'merge-builds', 'device-projects'])
            #memcache_delete_multi(['known_ids', 'last_changes', 'filtered', 'merge-builds', 'project', 'project-list'])
            #memcache.flush_all()

        self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
        self.response.out.write("Skipped %d of %d changes" % (skipped, len(changes)) + "\n")