예제 #1
0
def getDeathRow(archive, log, pool_root_override):
    """Return a Deathrow object for the archive supplied.

    :param archive: Use the publisher config for this archive to derive the
                    DeathRow object.
    :param log: Use this logger for script debug logging.
    :param pool_root_override: Use this pool root for the archive instead of
         the one provided by the publishing-configuration, it will be only
         used for PRIMARY archives.
    """
    log.debug("Grab publisher config.")
    pubconf = getPubConfig(archive)

    if (pool_root_override is not None
            and archive.purpose == ArchivePurpose.PRIMARY):
        pool_root = pool_root_override
    else:
        pool_root = pubconf.poolroot

    log.debug("Preparing on-disk pool representation.")

    diskpool_log = logging.getLogger("DiskPool")
    # Set the diskpool's log level to INFO to suppress debug output
    diskpool_log.setLevel(20)

    dp = DiskPool(pool_root, pubconf.temproot, diskpool_log)

    log.debug("Preparing death row.")
    return DeathRow(archive, dp, log)
예제 #2
0
def _getDiskPool(pubconf, log):
    """Return a DiskPool instance for a given PubConf.

    It ensures the given archive location matches the minimal structure
    required.
    """
    log.debug("Preparing on-disk pool representation.")
    dp = DiskPool(pubconf.poolroot, pubconf.temproot,
                  logging.getLogger("DiskPool"))
    # Set the diskpool's log level to INFO to suppress debug output
    dp.logger.setLevel(logging.INFO)

    return dp
예제 #3
0
    def getDeathRow(self, archive):
        """Return an `DeathRow` for the given archive.

        Created the temporary 'pool' and 'temp' directories and register
        a 'cleanup' to purge them after the test runs.
        """
        pool_path = tempfile.mkdtemp('-pool')
        temp_path = tempfile.mkdtemp('-pool-tmp')

        def clean_pool(pool_path, temp_path):
            shutil.rmtree(pool_path)
            shutil.rmtree(temp_path)

        self.addCleanup(clean_pool, pool_path, temp_path)

        logger = BufferLogger()
        diskpool = DiskPool(pool_path, temp_path, logger)
        return DeathRow(archive, diskpool, logger)
예제 #4
0
    def setUp(self):
        super(TestFTPArchive, self).setUp()
        switch_dbuser(config.archivepublisher.dbuser)

        self._distribution = getUtility(IDistributionSet)['ubuntutest']
        self._archive = self._distribution.main_archive
        self._config = getPubConfig(self._archive)
        self._config.setupArchiveDirs()
        self._sampledir = os.path.join(config.root, "lib", "lp",
                                       "archivepublisher", "tests", "apt-data")
        self._distsdir = self._config.distsroot
        self._confdir = self._config.miscroot
        self._pooldir = self._config.poolroot
        self._overdir = self._config.overrideroot
        self._listdir = self._config.overrideroot
        self._tempdir = self._config.temproot
        self._logger = BufferLogger()
        self._dp = DiskPool(self._pooldir, self._tempdir, self._logger)
        self._publisher = SamplePublisher(self._archive)
예제 #5
0
 def setUp(self):
     self.pool_path = mkdtemp()
     self.temp_path = mkdtemp()
     self.pool = DiskPool(self.pool_path, self.temp_path, BufferLogger())