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 get(self, branch, type, force=False):
     p_list = self._get_mem(branch, type)
     if not force and p_list is not None:
         logging.debug("---> DS: Projects cache hit")
         return p_list
     
     logging.debug("###> DS: Read project: branch '%s', type '%s'" % (branch, type))
     if type == '--all--':
         p_list = Project.gql("WHERE branch = :1 ORDER BY type, project", branch)
     else:
         p_list = Project.gql("WHERE branch = :1 AND type = :2 ORDER BY project", branch, type)
     
     return self._set_mem(p_list, branch, type)
Example #3
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")
Example #4
0
 def get(self):
     if allow_db_clear == False:
         self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
         self.response.out.write("This feature is disabled...\n")
         self.response.set_status(401)
         return
     db.delete(Project.all())
     db.delete(Change.all())
     memcache.flush_all()
     self.response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
     self.response.out.write("Database is empty...\n")
Example #5
0
def device_projects():
    projects = memcache.get('device-projects')

    if projects is not None:
        logging.debug("---> DS: Device project cache hit")
        return projects
    
    logging.debug("###> DS: read device projects")
    all_projects = Project.gql("WHERE type = 'device'")
    
    projects = []
    for p in all_projects:
        if not re.search(r'^(android_)?device_', p.project): continue
        projects.append(p.project)
    
    memcache.set('device-projects', projects)
    return projects