Пример #1
0
 def testExtractOver(self):
     with open('HelloWorld.tgz', 'rb') as stream:
         unpack.unpack_archive_over('ftp://foo/file.tgz',
                                    stream,
                                    self.tmpdir,
                                    extract='HelloWorld')
     self.assert_manifest('sha1=491678c37f77fadafbaae66b13d48d237773a68f')
Пример #2
0
	def apply(self, basedir):
		from zeroinstall.zerostore import unpack
		assert self.blocker.happened
		unpack.unpack_archive_over(self.stepdata.url, self.stream, basedir,
				extract = self.stepdata.extract,
				type=self.stepdata.type,
				start_offset = self.stepdata.start_offset or 0)
Пример #3
0
	def apply(self, basedir):
		"""@type basedir: str"""
		from zeroinstall.zerostore import unpack
		assert self.blocker is None or self.blocker.happened
		if self.stepdata.dest is not None:
			basedir = native_path_within_base(basedir, self.stepdata.dest)
			_ensure_dir_exists(basedir)
		unpack.unpack_archive_over(self.stepdata.url, self.stream, basedir,
				extract = self.stepdata.extract,
				type=self.stepdata.type,
				start_offset = self.stepdata.start_offset or 0)
Пример #4
0
	def apply(self, basedir):
		"""@type basedir: str"""
		from zeroinstall.zerostore import unpack
		assert self.blocker is None or self.blocker.happened
		if self.stepdata.dest is not None:
			basedir = native_path_within_base(basedir, self.stepdata.dest)
			_ensure_dir_exists(basedir)
		unpack.unpack_archive_over(self.stepdata.url, self.stream, basedir,
				extract = self.stepdata.extract,
				type=self.stepdata.type,
				start_offset = self.stepdata.start_offset or 0)
Пример #5
0
    def cook(self,
             required_digest,
             recipe,
             stores,
             force=False,
             impl_hint=None):
        """Follow a Recipe.
		@param impl_hint: the Implementation this is for (if any) as a hint for the GUI
		@see: L{download_impl} uses this method when appropriate"""
        # Maybe we're taking this metaphor too far?

        # Start downloading all the ingredients.
        streams = {}  # Streams collected from successful downloads

        # Start a download for each ingredient
        blockers = []
        for step in recipe.steps:
            blocker, stream = self.download_archive(step,
                                                    force=force,
                                                    impl_hint=impl_hint)
            assert stream
            blockers.append(blocker)
            streams[step] = stream

        while blockers:
            yield blockers
            tasks.check(blockers)
            blockers = [b for b in blockers if not b.happened]

        from zeroinstall.zerostore import unpack

        # Create an empty directory for the new implementation
        store = stores.stores[0]
        tmpdir = store.get_tmp_dir_for(required_digest)
        try:
            # Unpack each of the downloaded archives into it in turn
            for step in recipe.steps:
                stream = streams[step]
                stream.seek(0)
                unpack.unpack_archive_over(step.url,
                                           stream,
                                           tmpdir,
                                           extract=step.extract,
                                           type=step.type,
                                           start_offset=step.start_offset or 0)
            # Check that the result is correct and store it in the cache
            store.check_manifest_and_rename(required_digest, tmpdir)
            tmpdir = None
        finally:
            # If unpacking fails, remove the temporary directory
            if tmpdir is not None:
                from zeroinstall import support
                support.ro_rmtree(tmpdir)
Пример #6
0
	def cook(self, required_digest, recipe, stores, force = False, impl_hint = None):
		"""Follow a Recipe.
		@param impl_hint: the Implementation this is for (if any) as a hint for the GUI
		@see: L{download_impl} uses this method when appropriate"""
		# Maybe we're taking this metaphor too far?

		# Start downloading all the ingredients.
		streams = {}	# Streams collected from successful downloads

		# Start a download for each ingredient
		blockers = []
		for step in recipe.steps:
			blocker, stream = self.download_archive(step, force = force, impl_hint = impl_hint)
			assert stream
			blockers.append(blocker)
			streams[step] = stream

		while blockers:
			yield blockers
			tasks.check(blockers)
			blockers = [b for b in blockers if not b.happened]

		from zeroinstall.zerostore import unpack

		# Create an empty directory for the new implementation
		store = stores.stores[0]
		tmpdir = store.get_tmp_dir_for(required_digest)
		try:
			# Unpack each of the downloaded archives into it in turn
			for step in recipe.steps:
				stream = streams[step]
				stream.seek(0)
				unpack.unpack_archive_over(step.url, stream, tmpdir,
						extract = step.extract,
						type = step.type,
						start_offset = step.start_offset or 0)
			# Check that the result is correct and store it in the cache
			store.check_manifest_and_rename(required_digest, tmpdir)
			tmpdir = None
		finally:
			# If unpacking fails, remove the temporary directory
			if tmpdir is not None:
				from zeroinstall import support
				support.ro_rmtree(tmpdir)
Пример #7
0
	def testExtractOver(self):
		unpack.unpack_archive_over('ftp://foo/file.tgz', open('HelloWorld.tgz'), self.tmpdir, extract = 'HelloWorld')
		self.assert_manifest('sha1=491678c37f77fadafbaae66b13d48d237773a68f')
Пример #8
0
 def testExtractOver(self):
     with open("HelloWorld.tgz", "rb") as stream:
         unpack.unpack_archive_over("ftp://foo/file.tgz", stream, self.tmpdir, extract="HelloWorld")
     self.assert_manifest("sha1=491678c37f77fadafbaae66b13d48d237773a68f")