• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tasks.wait_for_blocker函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zeroinstall.support.tasks.wait_for_blocker函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for_blocker函数的具体用法?Python wait_for_blocker怎么用?Python wait_for_blocker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wait_for_blocker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testImplMirrorFails

	def testImplMirrorFails(self):
		with resourcewarnings_suppressed():
			trust.trust_db.trust_key('DE937DD411906ACF7C263B396FCF121BE2390E0B', 'example.com:8000')
			run_server('/Hello.xml',
					'/6FCF121BE2390E0B.gpg',
					server.Give404('/HelloWorld.tgz'),
					server.Give404('/0mirror/archive/http%3A%23%23example.com%3A8000%23HelloWorld.tgz'),
					server.Give404('/0mirror/feeds/http/example.com:8000/Hello.xml/impl/sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'))
			driver = Driver(requirements = Requirements('http://example.com:8000/Hello.xml'), config = self.config)
			self.config.mirror = 'http://example.com:8000/0mirror'

			refreshed = driver.solve_with_downloads()
			tasks.wait_for_blocker(refreshed)
			assert driver.solver.ready

			getLogger().setLevel(logging.ERROR)
			try:
				downloaded = driver.download_uncached_implementations()
				tasks.wait_for_blocker(downloaded)
				assert 0
			except download.DownloadError as ex:
				assert 'Missing: HelloWorld.tgz' in str(ex), ex

			self.assertEqual([
				'http://example.com:8000/Hello.xml',
				'http://example.com:8000/6FCF121BE2390E0B.gpg',
				# The original archive:
				'http://example.com:8000/HelloWorld.tgz',
				# Mirror of original archive:
				'http://example.com:8000/0mirror/archive/http%3A%23%23example.com%3A8000%23HelloWorld.tgz',
				# Mirror of implementation:
				'http://example.com:8000/0mirror/feeds/http/example.com:8000/Hello.xml/impl/sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
				], traced_downloads)
开发者ID:rammstein,项目名称:0install,代码行数:33,代码来源:testdownload.py


示例2: handle

def handle(config, options, args):
	"""@type config: L{zeroinstall.injector.config.Config}
	@type args: [str]"""
	if len(args) != 1:
		raise UsageError()

	app = config.app_mgr.lookup_app(args[0], missing_ok = True)
	if app is not None:
		sels = app.get_selections()

		r = app.get_requirements()
		do_select = r.parse_update_options(options) or options.refresh
		iface_uri = sels.interface
	else:
		iface_uri = model.canonical_iface_uri(args[0])
		r = None
		do_select = True

	if do_select or options.gui:
		sels = select.get_selections(config, options, iface_uri,
					select_only = False, download_only = True, test_callback = None, requirements = r)
		if not sels:
			sys.exit(1)	# Aborted by user
	else:
		dl = app.download_selections(sels)
		if dl:
			tasks.wait_for_blocker(dl)
			tasks.check(dl)

	if options.xml:
		select.show_xml(sels)
	if options.show:
		select.show_human(sels, config.stores)
		if app is not None and do_select:
			print(_("(use '0install update' to save the new parameters)"))
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:35,代码来源:download.py


示例3: testReplay

	def testReplay(self):
		with resourcewarnings_suppressed():
			old_out = sys.stdout
			try:
				sys.stdout = StringIO()
				getLogger().setLevel(ERROR)
				iface = self.config.iface_cache.get_interface('http://example.com:8000/Hello.xml')
				mtime = int(os.stat('Hello-new.xml').st_mtime)
				with open('Hello-new.xml', 'rb') as stream:
					self.config.iface_cache.update_feed_from_network(iface.uri, stream.read(), mtime + 10000)

				trust.trust_db.trust_key('DE937DD411906ACF7C263B396FCF121BE2390E0B', 'example.com:8000')
				run_server(server.Give404('/Hello.xml'), 'latest.xml', '/0mirror/keys/6FCF121BE2390E0B.gpg', 'Hello.xml')
				self.config.mirror = 'http://example.com:8000/0mirror'

				# Update from mirror (should ignore out-of-date timestamp)
				refreshed = self.config.fetcher.download_and_import_feed(iface.uri, self.config.iface_cache)
				tasks.wait_for_blocker(refreshed)

				# Update from upstream (should report an error)
				refreshed = self.config.fetcher.download_and_import_feed(iface.uri, self.config.iface_cache)
				try:
					tasks.wait_for_blocker(refreshed)
					raise Exception("Should have been rejected!")
				except model.SafeException as ex:
					assert "New feed's modification time is before old version" in str(ex)

				# Must finish with the newest version
				self.assertEqual(1342285569, self.config.iface_cache._get_signature_date(iface.uri))
			finally:
				sys.stdout = old_out
开发者ID:dabrahams,项目名称:0install,代码行数:31,代码来源:testdownload.py


示例4: get_selections

def get_selections(config, options, iface_uri, select_only, download_only, test_callback):
	"""Get selections for iface_uri, according to the options passed.
	Will switch to GUI mode if necessary.
	@param options: options from OptionParser
	@param iface_uri: canonical URI of the interface
	@param select_only: return immediately even if the selected versions aren't cached
	@param download_only: wait for stale feeds, and display GUI button as Download, not Run
	@return: the selected versions, or None if the user cancels
	@rtype: L{selections.Selections} | None
	"""
	if options.offline:
		config.network_use = model.network_offline

	iface_cache = config.iface_cache

	# Try to load it as a feed. If it is a feed, it'll get cached. If not, it's a
	# selections document and we return immediately.
	maybe_selections = iface_cache.get_feed(iface_uri, selections_ok = True)
	if isinstance(maybe_selections, selections.Selections):
		if not select_only:
			blocker = maybe_selections.download_missing(config)
			if blocker:
				logger.info(_("Waiting for selected implementations to be downloaded..."))
				tasks.wait_for_blocker(blocker)
		return maybe_selections

	r = requirements.Requirements(iface_uri)
	r.parse_options(options)

	return get_selections_for(r, config, options, select_only, download_only, test_callback)
开发者ID:dabrahams,项目名称:0install,代码行数:30,代码来源:select.py


示例5: testDistro

	def testDistro(self):
		with output_suppressed():
			native_url = 'http://example.com:8000/Native.xml'

			# Initially, we don't have the feed at all...
			master_feed = self.config.iface_cache.get_feed(native_url)
			assert master_feed is None, master_feed

			trust.trust_db.trust_key('DE937DD411906ACF7C263B396FCF121BE2390E0B', 'example.com:8000')
			run_server('Native.xml', '6FCF121BE2390E0B.gpg', '/key-info/key/DE937DD411906ACF7C263B396FCF121BE2390E0B')
			driver = Driver(requirements = Requirements(native_url), config = self.config)
			assert driver.need_download()

			solve = driver.solve_with_downloads()
			tasks.wait_for_blocker(solve)
			tasks.check(solve)

			master_feed = self.config.iface_cache.get_feed(native_url)
			assert master_feed is not None
			assert master_feed.implementations == {}

			distro_feed_url = master_feed.get_distro_feed()
			assert distro_feed_url is not None
			distro_feed = self.config.iface_cache.get_feed(distro_feed_url)
			assert distro_feed is not None
			assert len(distro_feed.implementations) == 2, distro_feed.implementations
开发者ID:dabrahams,项目名称:0install,代码行数:26,代码来源:testdownload.py


示例6: ensure_cached

def ensure_cached(uri, command = 'run', config = None):
	"""Ensure that an implementation of uri is cached.
	If not, it downloads one. It uses the GUI if a display is
	available, or the console otherwise.
	@param uri: the required interface
	@type uri: str
	@return: the selected implementations, or None if the user cancelled
	@rtype: L{zeroinstall.injector.selections.Selections}
	"""
	from zeroinstall.injector import policy, selections

	if config is None:
		from zeroinstall.injector.config import load_config
		config = load_config()
	p = policy.Policy(uri, command = command, config = config)
	p.freshness = 0		# Don't check for updates

	if p.need_download() or not p.ready:
		if os.environ.get('DISPLAY', None):
			return get_selections_gui(uri, ['--command', command])
		else:
			done = p.solve_and_download_impls()
			tasks.wait_for_blocker(done)

	return selections.Selections(p)
开发者ID:gvsurenderreddy,项目名称:zeroinstall,代码行数:25,代码来源:helpers.py


示例7: handle

def handle(config, options, args):
	if args:
		raise UsageError()

	if options.offline:
		config.network_use = model.network_offline

	def slave_raw_input(prompt = ""):
		ticket = take_ticket()
		send_json(["invoke", ticket, ["input", prompt]])
		while True:
			message = recv_json()
			if message[0] == 'return' and message[1] == ticket:
				reply = message[2]
				assert reply[0] == 'ok', reply
				return reply[1]
			else:
				handle_message(config, options, message)

	support.raw_input = slave_raw_input

	@tasks.async
	def handle_events():
		while True:
			logger.debug("waiting for stdin")
			yield tasks.InputBlocker(stdin, 'wait for commands from master')
			logger.debug("reading JSON")
			message = recv_json()
			logger.debug("got %s", message)
			if message is None: break
			handle_message(config, options, message)

	tasks.wait_for_blocker(handle_events())
开发者ID:rammstein,项目名称:0install,代码行数:33,代码来源:slave.py


示例8: add_digests

def add_digests(feed_path, implementation, config):
	root = qdom.Element(namespaces.XMLNS_IFACE, 'interface', {})
	name = qdom.Element(namespaces.XMLNS_IFACE, 'name', {})
	name.content = 'Test'
	summary = qdom.Element(namespaces.XMLNS_IFACE, 'summary', {})
	summary.content = 'testing'
	test_impl = qdom.Element(namespaces.XMLNS_IFACE, 'implementation', {'id': 'sha1new=1', 'version': '0'})
	root.childNodes = [name, summary, test_impl]

	for child in implementation.childNodes:
		if child.namespaceURI == namespaces.XMLNS_IFACE and child.localName in ('archive', 'file', 'recipe'):
			test_impl.childNodes.append(dom_to_qdom(child))

	feed = model.ZeroInstallFeed(root, local_path = feed_path)
	impl, = feed.implementations.values()
	assert impl.download_sources, "No retrieval methods in implementation!"
	method, = impl.download_sources

	basename_hrefs(method)

	# When fetcher asks FakeStores to check the digest, FakeStores instead stores the actual
	# digest on implementation.
	fake_stores = FakeStores(implementation, config.stores)
	blocker = config.fetcher.download_impl(impl, method, fake_stores)
	tasks.wait_for_blocker(blocker)
开发者ID:0install,项目名称:0template,代码行数:25,代码来源:digest.py


示例9: handle

def handle(config, options, args):
	if not args:
		raise UsageError()

	for x in args:
		if not os.path.isfile(x):
			raise SafeException(_("File '%s' does not exist") % x)
		logger.info(_("Importing from file '%s'"), x)
		with open(x, 'rb') as signed_data:
			data, sigs = gpg.check_stream(signed_data)
			doc = minidom.parseString(data.read())
			uri = doc.documentElement.getAttribute('uri')
			if not uri:
				raise SafeException(_("Missing 'uri' attribute on root element in '%s'") % x)
			logger.info(_("Importing information about interface %s"), uri)
			signed_data.seek(0)

			pending = PendingFeed(uri, signed_data)

			def run():
				keys_downloaded = tasks.Task(pending.download_keys(config.fetcher), "download keys")
				yield keys_downloaded.finished
				tasks.check(keys_downloaded.finished)
				if not config.iface_cache.update_feed_if_trusted(uri, pending.sigs, pending.new_xml):
					blocker = config.trust_mgr.confirm_keys(pending)
					if blocker:
						yield blocker
						tasks.check(blocker)
					if not config.iface_cache.update_feed_if_trusted(uri, pending.sigs, pending.new_xml):
						raise SafeException(_("No signing keys trusted; not importing"))

			task = tasks.Task(run(), "import feed")

			tasks.wait_for_blocker(task.finished)
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:34,代码来源:import.py


示例10: testDistro

	def testDistro(self):
		native_url = 'http://example.com:8000/Native.xml'

		# Initially, we don't have the feed at all...
		master_feed = self.config.iface_cache.get_feed(native_url)
		assert master_feed is None, master_feed

		trust.trust_db.trust_key('DE937DD411906ACF7C263B396FCF121BE2390E0B', 'example.com:8000')
		run_server('Native.xml', '6FCF121BE2390E0B.gpg', '/key-info/key/DE937DD411906ACF7C263B396FCF121BE2390E0B')
		out, err = self.run_ocaml(['download', native_url])
		assert not out, out
		assert "Can't find all required implementations" in err, err

		master_feed = self.config.iface_cache.get_feed(native_url, force = True)
		assert master_feed is not None
		assert master_feed.implementations == {}

		blocker = self.config.iface_cache.distro.fetch_candidates(master_feed)
		if blocker:
			tasks.wait_for_blocker(blocker)
		distro_feed_url = master_feed.get_distro_feed()
		assert distro_feed_url is not None
		distro_feed = self.config.iface_cache.get_feed(distro_feed_url)
		assert distro_feed is not None
		assert len(distro_feed.implementations) == 2, distro_feed.implementations
开发者ID:linuxmidhun,项目名称:0install,代码行数:25,代码来源:testdownload.py


示例11: ensure_cached

def ensure_cached(uri, command = 'run', config = None):
	"""Ensure that an implementation of uri is cached.
	If not, it downloads one. It uses the GUI if a display is
	available, or the console otherwise.
	@param uri: the required interface
	@type uri: str
	@return: the selected implementations, or None if the user cancelled
	@rtype: L{zeroinstall.injector.selections.Selections}
	"""
	from zeroinstall.injector.driver import Driver

	if config is None:
		from zeroinstall.injector.config import load_config
		config = load_config()

	from zeroinstall.injector.requirements import Requirements
	requirements = Requirements(uri)
	requirements.command = command

	d = Driver(config, requirements)

	if d.need_download() or not d.solver.ready:
		sels = get_selections_gui(uri, ['--command', command], use_gui = None)
		if sels != DontUseGUI:
			return sels
		done = d.solve_and_download_impls()
		tasks.wait_for_blocker(done)

	return d.solver.selections
开发者ID:gvsurenderreddy,项目名称:0install,代码行数:29,代码来源:helpers.py


示例12: downloadZeroFeed

def downloadZeroFeed(url):
    tasks.wait_for_blocker(download_info(url))

    try:
        zeroPath = ZeroFindPath(url)
        return zeroPath
    except:
        return False
开发者ID:Brainiarc7,项目名称:TS,代码行数:8,代码来源:zeroinstallHelper.py


示例13: testRenameFailure

	def testRenameFailure(self):
		recipe = model.Recipe()
		try:
			recipe.steps.append(model.RenameStep("missing-source", "dest"))
			blocker = self.config.fetcher.cook("sha256new_XXX", recipe, self.config.stores)
			tasks.wait_for_blocker(blocker)
			assert 0
		except model.SafeException as ex:
			assert "<rename> source 'missing-source' does not exist" in str(ex), ex
开发者ID:rammstein,项目名称:0install,代码行数:9,代码来源:testdownload.py


示例14: testDownloadIconFails

	def testDownloadIconFails(self):
		path = model.canonical_iface_uri(os.path.join(mydir, 'Binary.xml'))
		iface = self.config.iface_cache.get_interface(path)
		blocker = self.config.fetcher.download_icon(iface)
		try:
			tasks.wait_for_blocker(blocker)
			assert False
		except download.DownloadError as ex:
			assert "Error downloading http://localhost/missing.png" in str(ex), ex
开发者ID:rammstein,项目名称:0install,代码行数:9,代码来源:testdownload.py


示例15: download_missing_selections

def download_missing_selections(sels):
	from zeroinstall.support import tasks
	from zeroinstall.injector.config import load_config

	config = load_config()
	blocker = sels.download_missing(config)
	if blocker:
		logging.info("Waiting for selected implementations to be downloaded...")
		tasks.wait_for_blocker(blocker)
开发者ID:pombredanne,项目名称:0path,代码行数:9,代码来源:0path.py


示例16: doTest

	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()
		self.config.handler.allow_downloads = True

		_pk = pk.pk
		rm, = impl.download_sources
		dl = packagekit.PackageKitDownload('packagekit:' + rm.packagekit_id, hint = None,
				pk = _pk, packagekit_id = rm.packagekit_id, expected_size = rm.size)
		self.config.handler.monitor_download(dl)
		b = dl.downloaded

		tasks.wait_for_blocker(b)
		tasks.check(b)
		#self.assertEqual("/usr/bin/fixed", list(impls.values())[0].main)	# Fixup not used in Python now

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

		# Don't fetch it again
		tasks.wait_for_blocker(pk.fetch_candidates(["gimp"]))
开发者ID:afb,项目名称:0install,代码行数:57,代码来源:testpackagekit.py


示例17: testChunked

	def testChunked(self):
		if sys.version_info[0] < 3:
			return	# not a problem with Python 2
		run_server('chunked')
		dl = self.config.fetcher.download_url('http://localhost/chunked')
		tmp = dl.tempfile
		tasks.wait_for_blocker(dl.downloaded)
		tasks.check(dl.downloaded)
		tmp.seek(0)
		self.assertEqual(b'hello world', tmp.read())
		kill_server_process()
开发者ID:rammstein,项目名称:0install,代码行数:11,代码来源:testdownload.py


示例18: testRecipeLocal

	def testRecipeLocal(self):
		recipe = model.Recipe()
		blocker = self.config.fetcher.cook("sha256new_4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ", recipe, self.config.stores)
		tasks.wait_for_blocker(blocker)

		try:
			recipe.steps.append(model.RemoveStep("."))
			blocker = self.config.fetcher.cook("sha256new_XXX", recipe, self.config.stores)
			tasks.wait_for_blocker(blocker)
			assert 0
		except model.SafeException as ex:
			assert "path '.' is not within the base directory" in str(ex), ex
开发者ID:rammstein,项目名称:0install,代码行数:12,代码来源:testdownload.py


示例19: tearDown

	def tearDown(self):
		# Wait for all downloads to finish, otherwise they may interfere with other tests
		for dl in list(self.config.handler.monitored_downloads):
			try:
				tasks.wait_for_blocker(dl.downloaded)
			except:
				pass

		BaseTest.tearDown(self)
		kill_server_process()

		# Flush out ResourceWarnings
		import gc; gc.collect()
开发者ID:linuxmidhun,项目名称:0install,代码行数:13,代码来源:testdownload.py


示例20: doTest

	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"]))
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:51,代码来源:testpackagekit.py



注:本文中的zeroinstall.support.tasks.wait_for_blocker函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unpack.unpack_archive函数代码示例发布时间:2022-05-26
下一篇:
Python tasks.check函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap