Example #1
0
    def getPackage (self, filename, size, reget=False):
        """ Get one package, making sure it's the right size
            and that old versions will end deleted.
            Returns a list of really downloaded files. Could be empty.
        """
        ans= 0
        get= False

        url= ("%(repoUrl)s/" % self)+filename
        _file= os.path.normpath (("%(repoDir)s/" % self)+filename)

        tempDir = dirname (_file)
        makedirs (tempDir)

        # the desition to wether download a file or not is, unfortunately, complex
        try:
            s= os.stat (_file)
        except OSError, e:
            if e.errno==errno.ENOENT:
                # the file does not exist; download it
                logger.debug ("%s not present, marking for download" % _file)
                get= True
            else:
                # something else, can't decide
                raise e
Example #2
0
 def updateReleaseDatabases (self):
     """
     Move the downloaded databases over the old ones for the whole release
     """
     logger.info ('------ updating databases for %(repo)s/%(distro)s/%(release)s' % self)
     # get the databases relative paths
     # these can be more
     databases= self.finalReleaseDBs ()
     logger.debug (databases)
     for (database, critic) in databases:
         # logger.debug (self.__dict__)
         dst= os.path.normpath (("%(repoDir)s/" % self)+database)
         src= self.tempDir+'/'+dst
         try:
             makedirs (dirname (dst))
             rename (src, dst, overwrite=True, verbose=self.verbose)
             logger.debug ("keeping %s" % dst)
             self.keep[dst]= '%(repo)s/%(distro)s/%(release)s' % self
         except OSError, e:
             # better error report!
             if not critic:
                 logger.warn ('[Ign] %s (%s)' % (src, str (e)))
             else:
                 self.databasesFailed= True
                 raise e
Example #3
0
    def releaseDatabases (self, download=True):
        yield ('authors/00whois.html', False)
        # yield ('authors/00whois.xml', True)
        yield ('authors/01mailrc.txt.gz', False)
        yield ('authors/02STAMP', False)

        # CHECKSUMS' *are* databases :-|
        # download 00whois.xml and get CHECKSUMS'
        filename= '%(tempDir)s/%(repoDir)s/authors/00whois.xml' % self
        url= '%(repoUrl)s/authors/00whois.xml' % self
        if download:
            found= grab (filename, url, cont=False, progress=self.progress)
            if found!=0:
                raise ProtocolError (proto=url[:url.index (':')].upper (), code=found, url=url)

            whois= libxml2.parseFile(filename).getRootElement()
            whoisChild= whois.children
            while whoisChild:
                if whoisChild.name=='cpanid':
                    dataChild= whoisChild.children
                    while dataChild:
                        if dataChild.name=='id':
                            cpanId= dataChild.content.strip ()
                        if dataChild.name=='type':
                            cpanType= dataChild.content.strip ()
                        dataChild= dataChild.next

                    if cpanType=='author':
                        # authors/id/A/AB/ABIGAIL will be the real dir
                        initial= cpanId[:1]
                        initials= cpanId[:2]
                        chksum= "authors/id/%s/%s/%s/CHECKSUMS" % (initial, initials, cpanId)
                        self.checksums.append (chksum)
                        yield (chksum, False)

                        makedirs ("%s/authors/id/%s/%s/%s" % (self.repoDir, initial, initials, cpanId))
                        # authors/id/A/ABIGAIL and
                        # authors/id/ABIGAIL will be symlinks to
                        # authors/id/A/AB/ABIGAIL
                        # note they're relative ones.
                        symlink ("%s/%s" % (initials, cpanId),
                                 "%s/authors/id/%s/%s" % (self.repoDir, initial, cpanId), self.verbose)
                        symlink ("%s/%s/%s" % (initial, initials, cpanId),
                                 "%s/authors/id/%s" % (self.repoDir, cpanId), self.verbose)

                whoisChild= whoisChild.next
        else:
            for chksum in self.checksums:
                yield (chksum, False)