Logo Search packages:      
Sourcecode: falcon version File versions  Download package

def falcon::mirror::Mirror::update (   self  ) 

Synchronize local copy of the mirrors metadata with the main
   metadata

Definition at line 54 of file mirror.py.

00054                     :
        """Synchronize local copy of the mirrors metadata with the main
           metadata"""
        if not os.path.exists(self.rootdir):
            os.makedirs(self.rootdir)

        # Remove files that no longer exist or should no longer be mirrored
        existing = listdir(self.rootdir)
        for file in reversed(existing):
            if not os.path.exists(file):
                if os.path.isdir(os.path.join(self.rootdir, file)):
                    shutil.rmtree(os.path.join(self.rootdir, file))
                else:
                    os.unlink(os.path.join(self.rootdir, file))
        
        if os.path.exists(os.path.join(self.rootdir,'dists')):
            to_mirror = [str(x) for x in self.components]
            for p in os.listdir(os.path.join(self.rootdir, 'dists')):
                for c in os.listdir(os.path.join(self.rootdir, 'dists', p)):
                    if c in ('Release','Release.gpg','index.html'):
                        continue
                    if c.startswith('Contents-') and c.endswith('.gz'):
                        continue
                    if c.startswith('app-install-data') and c.endswith('.deb'):
                        continue
                    if os.path.join(p,c) not in to_mirror:
                        shutil.rmtree(os.path.join(self.rootdir,'dists',p,c))
                if len(os.listdir(os.path.join(self.rootdir, 'dists', p))) == 3:
                    shutil.rmtree(os.path.join(self.rootdir,'dists',p))

        # Copy over new(er) files
        filters = ['pool','.falcon']

        if not self.has_all():
            filters += [x.distpath for x in falcon.pocket.Pocket.objects.all()]
            filters += [x.distpath for x in falcon.pocket.Component.objects.all()]
            filters += [x.distpath for x in falcon.pocket.MetaComponent.objects.all()]
            
            for z in set([x.distpath for x in [y.pocket for y in self.components]] + [x.distpath for x in self.components]):
                filters.remove(z)
        to_copy = listdir('.', filters = filters)

        for file in to_copy:
            if os.path.isdir(file):
                if not os.path.exists(os.path.join(self.rootdir, file)):
                    os.makedirs(os.path.join(self.rootdir,file))
            else:
                if not os.path.exists(os.path.join(self.rootdir, file)) or falcon.util.newer(file, os.path.join(self.rootdir, file)):
                    shutil.copy(file, os.path.join(self.rootdir, file))

        from django.template import loader, Context
        pockets = falcon.pocket.Pocket.objects.filter(realcomponents__mirror = self).distinct()
        do_appinstall = False
        try:
            do_appinstall = falcon.plugins.app_install.AppInstallDataPlugin.conf.enabled
        except:
            pass
        if not self.has_all():
            template = loader.get_template('pocket.html')
            for pocket in pockets:
                # Generate proper release files and sign them
                components = [x for x in self.components if x.pocket == pocket]
                context = Context({'p': pocket, 'conf': falcon.conf, 'dots': '../../', 'components': components, 'do_appinstall': do_appinstall})
                falcon.util.writefile(os.path.join(self.rootdir, pocket.distpath, 'index.html'),template.render(context))

        template = loader.get_template('base.html')
        mirrors = falcon.mirror.Mirror.objects.all().order_by('name')
        context = Context({'pockets': pockets, 'conf': falcon.conf, 'mirrors': mirrors, 'mirror': self, 'do_appinstall': do_appinstall})
        falcon.util.writefile(os.path.join(self.rootdir, 'index.html'),template.render(context))

    @falcon.util.timer
    @falcon.plugin.wrap_plugin


Generated by  Doxygen 1.6.0   Back to index