コード例 #1
0
ファイル: testdownload.py プロジェクト: rammstein/0install
	def setUp(self):
		BaseTest.setUp(self)

		self.config.handler.allow_downloads = True
		self.config.key_info_server = 'http://localhost:3333/key-info'
		self.config.fetcher = fetch.Fetcher(self.config)

		child_config = config.Config()
		child_config.key_info_server = 'http://localhost:3333/key-info'
		child_config.save_globals()

		stream = tempfile.TemporaryFile()
		stream.write(data.thomas_key)
		stream.seek(0)
		gpg.import_key(stream)
		stream.close()

		trust.trust_db.watchers = []

		helpers.get_selections_gui = raise_gui

		global ran_gui
		ran_gui = False

		global traced_downloads
		traced_downloads = []
コード例 #2
0
ファイル: cli.py プロジェクト: sugar-activities/4037-activity
def _download_missing_selections(options, sels):
	from zeroinstall.injector import fetch
	from zeroinstall.injector.handler import Handler
	handler = Handler(dry_run = options.dry_run)
	fetcher = fetch.Fetcher(handler)
	blocker = sels.download_missing(iface_cache, fetcher)
	if blocker:
		logging.info(_("Waiting for selected implementations to be downloaded..."))
		handler.wait_for_blocker(blocker)
コード例 #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 setUp(self):
        BaseTest.setUp(self)

        self.config.handler.allow_downloads = True
        self.config.key_info_server = 'http://localhost:3333/key-info'

        self.config.fetcher = fetch.Fetcher(self.config)

        stream = tempfile.TemporaryFile()
        stream.write(data.thomas_key)
        stream.seek(0)
        gpg.import_key(stream)
        self.child = None

        trust.trust_db.watchers = []
コード例 #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 testUnknownAlg(self):
		self.cache_iface(foo_iface_uri,
"""<?xml version="1.0" ?>
<interface
 uri="%s"
 xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
  <name>Foo</name>
  <summary>Foo</summary>
  <description>Foo</description>
  <implementation main='.' id='unknown=123' version='1.0'>
    <archive href='http://foo/foo.tgz' size='100'/>
  </implementation>
</interface>""" % foo_iface_uri)
		self.config.fetcher = fetch.Fetcher(self.config)
		driver = Driver(requirements = Requirements(foo_iface_uri), config = self.config)
		try:
			assert driver.need_download()
			download_and_execute(driver, [])
		except model.SafeException as ex:
			assert "Use '_' not '=' for new algorithms, in unknown=123" in str(ex), ex
コード例 #7
0
    def testUnknownAlg(self):
        self.cache_iface(
            foo_iface_uri, """<?xml version="1.0" ?>
<interface
 uri="%s"
 xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
  <name>Foo</name>
  <summary>Foo</summary>
  <description>Foo</description>
  <implementation main='.' id='unknown=123' version='1.0'>
    <archive href='http://foo/foo.tgz' size='100'/>
  </implementation>
</interface>""" % foo_iface_uri)
        self.config.fetcher = fetch.Fetcher(self.config)
        policy = Policy(foo_iface_uri, config=self.config)
        policy.freshness = 0
        try:
            assert policy.need_download()
            download_and_execute(policy, [])
        except model.SafeException as ex:
            assert 'Unknown digest algorithm' in str(ex)
コード例 #8
0
ファイル: testdownload.py プロジェクト: dabrahams/0install
    def setUp(self):
        BaseTest.setUp(self)

        background._detach = lambda: False

        self.config.handler.allow_downloads = True
        self.config.key_info_server = 'http://localhost:3333/key-info'

        self.config.fetcher = fetch.Fetcher(self.config)

        stream = tempfile.TemporaryFile()
        stream.write(data.thomas_key)
        stream.seek(0)
        gpg.import_key(stream)
        stream.close()

        trust.trust_db.watchers = []

        helpers.get_selections_gui = raise_gui

        global ran_gui
        ran_gui = False
コード例 #9
0
 def fetcher(self):
     if not self._fetcher:
         from zeroinstall.injector import fetch
         self._fetcher = fetch.Fetcher(self)
     return self._fetcher
コード例 #10
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)