Beispiel #1
0
    def handle(self, *args, **options):

        self.stdout.write('Started.\n')
        logger.info("Start")
        t_start = time.time() 

        potonly = options['potonly']
        
        BOT_USERNAME = getattr(settings, 'BOT_USERNAME', 'bot')
        BOT_USER = User.objects.get(username=BOT_USERNAME)

        projects = Project.objects.filter(enabled=True, read_only=False)
        
        b = None
        failedProjects = []
        try:
            for project in projects:
                teams = project.teams.all()
                for release in project.releases.filter(enabled=True, read_only=False):
                    for component in project.components.all():

                        try:
                            b = BuildCache.objects.get(component=component, release=release)
                            if b.is_locked:
                                logger.info("%s - %s is locked" % (release, component))
                                break
                        except:
                            b = BuildCache.objects.create(component=component,
                                                      release=release)
                        
                        b.lock()

                        try:
                            if not potonly:
                                for team in teams:
                                    if project.slug in failedProjects:
                                        self.stdout.write("Project %s skipped because previous fails\n" % project.slug)
                                        logger.info("Project %s skipped because previous fails" % project.slug)
                                        break
                                    
                                    logger.info("Refresh project %s, release %s, component %s, team %s" % (project.name,
                                                                                                          release.name,
                                                                                                          component.name,
                                                                                                          team.language.name))
                                    man = Manager(project, release, component, team.language, user=BOT_USER)
                                    
                                    try:
                                        logger.debug('Create lock')
                                        with LockRepo(project.slug,
                                                      release.slug,
                                                      component.slug,
                                                      team.language.code) as lock:
                                            logger.debug('Refresh')
                                            man.revert()
                                            man.refresh()
                                        logger.debug('Process Stats')
                                        man.update_stats(False)
                                    except Exception, e:
                                        failedProjects.append(project.slug)
                                        logger.error(e)
                                        traceback.print_exc(file=sys.stdout)
                                    finally:
                                        del man
                                    
                            if component.potlocation:
                                logger.info("Processing POT")
                                repo = POTUpdater(project, release, component)
                                try:
                                    repo.update_stats(True)
                                except Exception, e:
                                    logger.error(e)
                                    traceback.print_exc(file=sys.stdout)
                                finally:
                                    del repo
Beispiel #2
0
                                     if dorefresh:
                                         man.revert()
                                         b.setrev(man.refresh())
                                     man.update_stats(False)
                             except Exception, e:
                                 failedProjects.append(project.slug)
                                 logger.error(e)
                                 traceback.print_exc(file=sys.stdout)
                             finally:
                                 del man
                             
                         if component.potlocation:
                             logger.info("Processing POT")
                             repo = POTUpdater(project, release, component)
                             try:
                                 repo.update_stats(dorefresh)
                             except Exception, e:
                                 logger.error(e)
                                 traceback.print_exc(file=sys.stdout)
                             finally:
                                 del repo
                                 
                             filelst = POFile.objects.filter(component=component, release=release)
                             for pofl in filelst:
                                 potnotification.check_notification(pofl, None, True)
                         else:
                             logger.debug("POT skipped")
 
                         b.unlock()
                         
     except Exception, e: