コード例 #1
0
    def packagekit(self):
        """For use by subclasses.
		@rtype: L{packagekit.PackageKit}"""
        if not self._packagekit:
            from zeroinstall.injector import packagekit
            self._packagekit = packagekit.PackageKit()
        return self._packagekit
コード例 #2
0
	def testNoPackageKit(self):
		imp.reload(packagekit)
		pk = packagekit.PackageKit()
		assert not pk.available

		factory = Exception("not called")
		pk.get_candidates('gimp', factory, 'package:null')
コード例 #3
0
	def doTest(self):
		imp.reload(packagekit)
		pk = packagekit.PackageKit()
		assert pk.available

		# Check none is found yet
		factory = Exception("not called")
		pk.get_candidates('gimp', factory, 'package:test')

		blocker = pk.fetch_candidates(["gimp"])
		blocker2 = pk.fetch_candidates(["gimp"])		# Check batching too

		@tasks.async
		def wait():
			yield blocker, blocker2
			if blocker.happened:
				tasks.check(blocker)
			else:
				tasks.check(blocker2)
		tasks.wait_for_blocker(wait())

		impls = {}
		def factory(impl_id, only_if_missing, installed):
			assert impl_id.startswith('package:')
			assert only_if_missing is True
			assert installed is False

			feed = None

			impl = model.DistributionImplementation(feed, impl_id, self)
			impl.installed = installed
			impls[impl_id] = impl
			return impl

		pk.get_candidates('gimp', factory, 'package:test')
		self.assertEqual(["package:test:gimp:2.6.8-2:x86_64"], list(impls.keys()))
		self.assertEqual(False, list(impls.values())[0].installed)

		impl, = impls.values()
		fetcher = fetch.Fetcher(config = self.config)
		self.config.handler.allow_downloads = True
		b = fetcher.download_impl(impl, impl.download_sources[0], stores = None)
		tasks.wait_for_blocker(b)
		tasks.check(b)
		self.assertEqual("/usr/bin/fixed", list(impls.values())[0].main)

		tasks.wait_for_blocker(blocker)
		tasks.wait_for_blocker(blocker2)

		# Don't fetch it again
		tasks.wait_for_blocker(pk.fetch_candidates(["gimp"]))
コード例 #4
0
	def testNoDBUS(self):
		import dbus
		old_dbus = dbus
		try:
			sys.meta_path.insert(0, self)
			del sys.modules['dbus']

			imp.reload(packagekit)

			pk = packagekit.PackageKit()
			assert pk.available == False

			factory = Exception("not called")
			pk.get_candidates('gimp', factory, 'package:null')
		finally:
			sys.modules['dbus'] = old_dbus
コード例 #5
0
    def testPackageKit05(self):
        #import logging; logging.getLogger().setLevel(logging.DEBUG)

        dbus.system_services['org.freedesktop.PackageKit'] = {
            '/org/freedesktop/PackageKit': PackageKit05(),
            '/tid/1': PackageKit05.Tid1(),
            '/tid/2': PackageKit05.Tid2(),
            '/tid/3': PackageKit05.Install(),
        }
        reload(packagekit)
        pk = packagekit.PackageKit()
        assert pk.available

        factory = Exception("not called")
        pk.get_candidates('gimp', factory, 'package:test')

        blocker = pk.fetch_candidates(["gimp"])
        tasks.wait_for_blocker(blocker)
        tasks.check(blocker)

        impls = {}

        def factory(impl_id, only_if_missing, installed):
            assert impl_id.startswith('package:')
            assert only_if_missing is True
            assert installed is False

            feed = None

            impl = model.DistributionImplementation(feed, impl_id, self)
            impl.installed = installed
            impls[impl_id] = impl
            return impl

        pk.get_candidates('gimp', factory, 'package:test')
        self.assertEquals(["package:test:gimp:2.6.8-2:x86_64"], impls.keys())

        impl, = impls.values()
        fetcher = fetch.Fetcher(config=self.config)
        self.config.handler.allow_downloads = True
        b = fetcher.download_impl(impl, impl.download_sources[0], stores=None)
        tasks.wait_for_blocker(b)
        tasks.check(b)
コード例 #6
0
	def testPackageKit05(self):
		#import logging
		#_logger_pk = logging.getLogger('0install.packagekit')
		#_logger_pk.setLevel(logging.DEBUG)

		pk05 = PackageKit05()

		dbus.system_services['org.freedesktop.PackageKit'] = {
			'/org/freedesktop/PackageKit': pk05,
			'/tid/1': PackageKit05.Tid1(),
			'/tid/2': PackageKit05.Tid2(),
			'/tid/3': PackageKit05.Install(),
		}
		imp.reload(packagekit)
		pk = packagekit.PackageKit()
		assert pk.available

		# Check none is found yet
		factory = Exception("not called")
		pk.get_candidates('gimp', factory, 'package:test')

		blocker = pk.fetch_candidates(["gimp"])
		blocker2 = pk.fetch_candidates(["gimp"])		# Check batching too

		@tasks.async
		def wait():
			yield blocker, blocker2
			if blocker.happened:
				tasks.check(blocker)
			else:
				tasks.check(blocker2)
		tasks.wait_for_blocker(wait())

		impls = {}
		def factory(impl_id, only_if_missing, installed):
			assert impl_id.startswith('package:')
			assert only_if_missing is True
			assert installed is False

			feed = None

			impl = model.DistributionImplementation(feed, impl_id, self)
			impl.installed = installed
			impls[impl_id] = impl
			return impl

		pk.get_candidates('gimp', factory, 'package:test')
		self.assertEqual(["package:test:gimp:2.6.8-2:x86_64"], list(impls.keys()))
		self.assertEqual(False, list(impls.values())[0].installed)

		impl, = impls.values()
		fetcher = fetch.Fetcher(config = self.config)
		self.config.handler.allow_downloads = True
		b = fetcher.download_impl(impl, impl.download_sources[0], stores = None)
		tasks.wait_for_blocker(b)
		tasks.check(b)
		self.assertEqual("/usr/bin/fixed", list(impls.values())[0].main)

		tasks.wait_for_blocker(blocker)
		tasks.wait_for_blocker(blocker2)

		# Don't fetch it again
		tasks.wait_for_blocker(pk.fetch_candidates(["gimp"]))
		self.assertEqual(3, pk05.x)