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

Python model.canonical_iface_uri函数代码示例

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

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



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

示例1: testMan

	def testMan(self):
		out, err = self.run_0install(['man', '--help'])
		assert out.lower().startswith("usage:")

		# Wrong number of args: pass-through
		self.check_man(['git', 'config'], ('man', 'git', 'config'))
		self.check_man([], ('man',))

		alias_path = os.path.join(mydir, '..', '0alias')
		local_feed = os.path.join(mydir, 'Local.xml')
		launcher_script = os.path.join(apps.find_bin_dir(), 'my-test-alias')
		with open(launcher_script, 'w') as stream:
			alias.write_script(stream, model.canonical_iface_uri(local_feed), None)
		self.check_man(['my-test-alias'], 'tests/test-echo.1')

		self.check_man(['__i_dont_exist'], '__i_dont_exist')
		self.check_man(['ls'], 'ls')

		# No man-page
		binary_feed = os.path.join(mydir, 'Command.xml')
		launcher_script = os.path.join(apps.find_bin_dir(), 'my-binary-alias')
		with open(launcher_script, 'w') as stream:
			alias.write_script(stream, model.canonical_iface_uri(binary_feed), None)

		out, err = self.run_0install(['man', 'my-binary-alias'])
		assert not err, err
		assert "No matching manpage was found for 'my-binary-alias'" in out, out

		with open(os.path.join(self.config_home, 'bad-unicode'), 'wb') as stream:
			stream.write(bytes([198, 65]))
		self.check_man(['bad-unicode'], 'bad-unicode')
开发者ID:dsqmoore,项目名称:0install,代码行数:31,代码来源:testinstall.py


示例2: testCanonical

	def testCanonical(self):
		try:
			model.canonical_iface_uri('http://foo')
			assert False
		except model.SafeException as ex:
			assert 'Missing /' in str(ex)

		self.assertEquals('http://foo/',
				model.canonical_iface_uri('http://foo/'))
		try:
			model.canonical_iface_uri('bad-name')
			assert False
		except model.SafeException as ex:
			assert 'Bad interface name' in str(ex)
开发者ID:gvsurenderreddy,项目名称:zeroinstall,代码行数:14,代码来源:testmodel.py


示例3: testSelect

	def testSelect(self):
		out, err = self.run_0install(['select'])
		assert out.lower().startswith("usage:")
		assert '--xml' in out

		out, err = self.run_0install(['select', 'Local.xml'])
		assert not err, err
		assert 'Version: 0.1' in out

		out, err = self.run_0install(['select', 'Local.xml', '--command='])
		assert not err, err
		assert 'Version: 0.1' in out

		local_uri = model.canonical_iface_uri('Local.xml')
		out, err = self.run_0install(['select', 'Local.xml'])
		assert not err, err
		assert 'Version: 0.1' in out

		out, err = self.run_0install(['select', 'Local.xml', '--xml'])
		sels = selections.Selections(qdom.parse(BytesIO(str(out).encode('utf-8'))))
		assert sels.selections[local_uri].version == '0.1'

		out, err = self.run_0install(['select', 'selections.xml'])
		assert not err, err
		assert 'Version: 1\n' in out
		assert '(not cached)' in out

		out, err = self.run_0install(['select', 'runnable/RunExec.xml'])
		assert not err, err
		assert 'Runner' in out, out
开发者ID:dsqmoore,项目名称:0install,代码行数:30,代码来源:testinstall.py


示例4: testDownload

	def testDownload(self):
		out, err = self.run_0install(['download'])
		assert out.lower().startswith("usage:")
		assert '--show' in out

		out, err = self.run_0install(['download', 'Local.xml', '--show'])
		assert not err, err
		assert 'Version: 0.1' in out

		local_uri = model.canonical_iface_uri('Local.xml')
		out, err = self.run_0install(['download', 'Local.xml', '--xml'])
		assert not err, err
		sels = selections.Selections(qdom.parse(BytesIO(str(out).encode('utf-8'))))
		assert sels.selections[local_uri].version == '0.1'

		out, err = self.run_0install(['download', 'Local.xml', '--show', '--with-store=/foo'])
		assert not err, err
		assert self.config.stores.stores[-1].dir == '/foo'

		out, err = self.run_0install(['download', '--offline', 'selections.xml'])
		assert 'Would download' in err
		self.config.network_use = model.network_full

		self.config.stores = TestStores()
		digest = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
		self.config.fetcher.allow_download(digest)
		out, err = self.run_0install(['download', 'Hello.xml', '--show'])
		assert not err, err
		assert self.config.stores.lookup_any([digest]).startswith('/fake')
		assert 'Version: 1\n' in out

		out, err = self.run_0install(['download', '--offline', 'selections.xml', '--show'])
		assert '/fake_store' in out
		self.config.network_use = model.network_full
开发者ID:dabrahams,项目名称:0install,代码行数:34,代码来源:testinstall.py


示例5: handle

def handle(config, options, args):
    if len(args) == 2:
        iface = config.iface_cache.get_interface(model.canonical_iface_uri(args[0]))
        feed_url = model.canonical_iface_uri(args[1])

        feed_import = add_feed.find_feed_import(iface, feed_url)
        if not feed_import:
            raise SafeException(
                _("Interface %(interface)s has no feed %(feed)s") % {"interface": iface.uri, "feed": feed_url}
            )
        iface.extra_feeds.remove(feed_import)
        writer.save_interface(iface)
    elif len(args) == 1:
        add_feed.handle(config, options, args, add_ok=False, remove_ok=True)
    else:
        raise UsageError()
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:16,代码来源:remove_feed.py


示例6: testAlias

	def testAlias(self):
		local_feed = model.canonical_iface_uri(os.path.join(mydir, 'Local.xml'))
		alias_path = os.path.join(mydir, '..', '0alias')
		child = subprocess.Popen([alias_path, 'local-app', local_feed], stdout = subprocess.PIPE, stderr = subprocess.PIPE, universal_newlines = True)
		out, err = child.communicate()
		assert 'ERROR: "0alias" has been removed; use "0install add" instead' in err, err
		assert not out, out
开发者ID:rammstein,项目名称:0install,代码行数:7,代码来源:testinstall.py


示例7: testDownload

    def testDownload(self):
        out, err = self.run_0install(["download"])
        assert out.lower().startswith("usage:")
        assert "--show" in out

        out, err = self.run_0install(["download", "Local.xml", "--show"])
        assert not err, err
        assert "Version: 0.1" in out

        local_uri = model.canonical_iface_uri("Local.xml")
        out, err = self.run_0install(["download", "Local.xml", "--xml"])
        assert not err, err
        sels = selections.Selections(qdom.parse(StringIO(str(out))))
        assert sels.selections[local_uri].version == "0.1"

        out, err = self.run_0install(["download", "Local.xml", "--show", "--with-store=/foo"])
        assert not err, err
        assert self.config.stores.stores[-1].dir == "/foo"

        out, err = self.run_0install(["download", "--offline", "selections.xml"])
        assert "Would download" in err
        self.config.network_use = model.network_full

        self.config.stores = TestStores()
        digest = "sha1=3ce644dc725f1d21cfcf02562c76f375944b266a"
        self.config.fetcher.allow_download(digest)
        out, err = self.run_0install(["download", "Hello.xml", "--show"])
        assert not err, err
        assert self.config.stores.lookup_any([digest]).startswith("/fake")
        assert "Version: 1\n" in out

        out, err = self.run_0install(["download", "--offline", "selections.xml", "--show"])
        assert "/fake_store" in out
        self.config.network_use = model.network_full
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:34,代码来源:testinstall.py


示例8: testSelect

    def testSelect(self):
        out, err = self.run_0install(["select"])
        assert out.lower().startswith("usage:")
        assert "--xml" in out

        out, err = self.run_0install(["select", "Local.xml"])
        assert not err, err
        assert "Version: 0.1" in out

        out, err = self.run_0install(["select", "Local.xml", "--command="])
        assert not err, err
        assert "Version: 0.1" in out

        local_uri = model.canonical_iface_uri("Local.xml")
        out, err = self.run_0install(["select", "Local.xml"])
        assert not err, err
        assert "Version: 0.1" in out

        out, err = self.run_0install(["select", "Local.xml", "--xml"])
        sels = selections.Selections(qdom.parse(StringIO(str(out))))
        assert sels.selections[local_uri].version == "0.1"

        out, err = self.run_0install(["select", "selections.xml"])
        assert not err, err
        assert "Version: 1\n" in out
        assert "(not cached)" in out

        out, err = self.run_0install(["select", "runnable/RunExec.xml"])
        assert not err, err
        assert "Runner" in out, out
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:30,代码来源:testinstall.py


示例9: do_autocompile

def do_autocompile(args):
	"""autocompile [--gui] URI"""

	parser = OptionParser(usage="usage: %prog autocompile [options]")

	parser.add_option('', "--gui", help="graphical interface", action='store_true')
	(options, args2) = parser.parse_args(args)
	if len(args2) != 1:
		raise __main__.UsageError()

	if options.gui:
		h = GUIHandler()
	elif os.isatty(1):
		h = handler.ConsoleHandler()
	else:
		h = handler.Handler()
	config = load_config(handler = h)
	config._iface_cache = AutocompileCache()

	iface_uri = model.canonical_iface_uri(args2[0])
	if options.gui:
		compiler = GTKAutoCompiler(config, iface_uri, options)
	else:
		compiler = AutoCompiler(config, iface_uri, options)

	compiler.build()
开发者ID:dabrahams,项目名称:0compile,代码行数:26,代码来源:autocompile.py


示例10: 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


示例11: handle

def handle(config, options, args):
	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)
		iface_uri = sels.interface
	else:
		iface_uri = model.canonical_iface_uri(args[0])
		do_select = True

	if do_select or options.gui:
		sels = get_selections(config, options, iface_uri,
					select_only = True, download_only = False, test_callback = None)
		if not sels:
			sys.exit(1)	# Aborted by user

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


示例12: handle

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

	prog_args = args[1:]

	def test_callback(sels):
		from zeroinstall.injector import run
		return run.test_selections(sels, prog_args,
					     False,	# dry-run
					     options.main)

	app = config.app_mgr.lookup_app(args[0], missing_ok = True)
	if app is not None:
		sels = app.get_selections(may_update = True, use_gui = options.gui)
		r = app.get_requirements()
		do_select = r.parse_update_options(options)
		iface_uri = sels.interface
	else:
		iface_uri = model.canonical_iface_uri(args[0])
		do_select = True

	if do_select or options.gui:
		sels = select.get_selections(config, options, iface_uri,
					select_only = False, download_only = False,
					test_callback = test_callback)
		if not sels:
			sys.exit(1)	# Aborted by user

	from zeroinstall.injector import run
	run.execute_selections(sels, prog_args, dry_run = options.dry_run, main = options.main, wrapper = options.wrapper, stores = config.stores)
开发者ID:res2k,项目名称:0install,代码行数:33,代码来源:run.py


示例13: handle

def handle(config, options, args):
	if len(args) == 2:
		iface = config.iface_cache.get_interface(model.canonical_iface_uri(args[0]))
		try:
			feed_url = model.canonical_iface_uri(args[1])
		except SafeException:
			feed_url = args[1]		# File might not exist any longer

		feed_import = add_feed.find_feed_import(iface, feed_url)
		if not feed_import:
			raise SafeException(_('Interface %(interface)s has no feed %(feed)s') %
						{'interface': iface.uri, 'feed': feed_url})
		iface.extra_feeds.remove(feed_import)
		writer.save_interface(iface)
	elif len(args) == 1:
		add_feed.handle(config, options, args, add_ok = False, remove_ok = True)
	else:
		raise UsageError()
开发者ID:dsqmoore,项目名称:0install,代码行数:18,代码来源:remove_feed.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: testAlias

	def testAlias(self):
		local_feed = model.canonical_iface_uri(os.path.join(mydir, 'Local.xml'))
		alias_path = os.path.join(mydir, '..', '0alias')
		child = subprocess.Popen([alias_path, 'local-app', local_feed], stdout = subprocess.PIPE, stderr = subprocess.STDOUT, universal_newlines = True)
		out, err = child.communicate()
		assert '("0alias" is deprecated; using "0install add" instead)' in out, out
		assert not err, err

		app = self.config.app_mgr.lookup_app('local-app')
		assert app.get_requirements().interface_uri == local_feed
开发者ID:dsqmoore,项目名称:0install,代码行数:10,代码来源:testinstall.py


示例16: handle

def handle(config, options, args):
	if len(args) != 1: raise UsageError()
	uri = model.canonical_iface_uri(args[0])
	iface = config.iface_cache.get_interface(uri)

	if iface.extra_feeds:
		for f in iface.extra_feeds:
			print(f.uri)
	else:
		print(_("(no feeds)"))
开发者ID:dabrahams,项目名称:0install,代码行数:10,代码来源:list_feeds.py


示例17: handle

def handle(config, options, args):
	if len(args) != 1:
		raise UsageError()

	assert not options.offline

	iface_uri = model.canonical_iface_uri(args[0])

	old_gui = options.gui

	# Select once in offline console mode to get the old values
	options.offline = True
	options.gui = False
	options.refresh = False

	try:
		old_sels = select.get_selections(config, options, iface_uri,
					select_only = True, download_only = False, test_callback = None)
	except SafeException:
		old_selections = {}
	else:
		if old_sels is None:
			old_selections = {}
		else:
			old_selections = old_sels.selections

	# Download in online mode to get the new values
	config.network_use = model.network_full
	options.offline = False
	options.gui = old_gui
	options.refresh = True

	sels = select.get_selections(config, options, iface_uri,
				select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	changes = False

	for iface, old_sel in old_selections.iteritems():
		new_sel = sels.selections.get(iface, None)
		if new_sel is None:
			print _("No longer used: %s") % iface
			changes = True
		elif old_sel.version != new_sel.version:
			print _("%s: %s -> %s") % (iface, old_sel.version, new_sel.version)
			changes = True

	for iface, new_sel in sels.selections.iteritems():
		if iface not in old_selections:
			print _("%s: new -> %s") % (iface, new_sel.version)
			changes = True

	if not changes:
		print _("No updates found.")
开发者ID:gvsurenderreddy,项目名称:zeroinstall,代码行数:55,代码来源:update.py


示例18: finish

		def finish():
			import xdgutils
			iface = iface_cache.get_interface(model.canonical_iface_uri(uri.get_text()))

			try:
				icon_path = iface_cache.get_icon_path(iface)
				xdgutils.add_to_menu(iface, icon_path, categories[category.get_active()])
			except SafeException, ex:
				box = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, str(ex))
				box.run()
				box.destroy()
开发者ID:pombredanne,项目名称:zero-install,代码行数:11,代码来源:addbox.py


示例19: do_setup

def do_setup(args, get_dir_callback = None):
	"setup [ SOURCE-URI [ DIR ] ]"
	if len(args) == 0:
		assert get_dir_callback is None
		buildenv = BuildEnv()
		interface = buildenv.interface
		assert interface
		create_dir = None
		buildenv.get_selections(prompt = True)
	else:
		buildenv = BuildEnv(need_config = False)
		interface = args[0]
		if get_dir_callback:
			assert len(args) == 1
		if len(args) == 1:
			create_dir = os.path.basename(interface)
			if create_dir.endswith('.xml'):
				create_dir = create_dir[:-4]
			if create_dir.startswith('alias:'):
				create_dir = create_dir.split(':', 1)[1]
			assert os.path.dirname(create_dir) == ''
			assert create_dir != os.path.curdir
			if get_dir_callback:
				create_dir = get_dir_callback(create_dir)
		elif len(args) == 2:
			create_dir = args[1]
			if create_dir == '.':
				create_dir = None
		else:
			raise __main__.UsageError()

		iface_uri = model.canonical_iface_uri(args[0])
		if os.path.isabs(iface_uri):
			root = qdom.parse(file(iface_uri))
			if root.uri == namespaces.XMLNS_IFACE and root.name == 'selections':
				# Looks like this is a selections file, not an interface.
				buildenv.config.set('compile', 'selections', iface_uri)
				iface_uri = root.getAttribute('interface')
		buildenv.config.set('compile', 'interface', iface_uri)

		if create_dir and os.path.exists(create_dir):
			raise SafeException("Directory '%s' already exists." % create_dir)
		buildenv.get_selections()

	if create_dir:
		try:
			os.mkdir(create_dir)
		except:
			print >>sys.stderr, "Failed to create new directory '%s'" % os.path.abspath(create_dir)
			raise
		os.chdir(create_dir)
		print "Created directory %s" % create_dir

	buildenv.save()
开发者ID:dabrahams,项目名称:0compile,代码行数:54,代码来源:setup.py


示例20: testReplacedConflicts

	def testReplacedConflicts(self):
		self.import_feed('http://localhost:8000/Hello', 'Hello')
		s = solver.DefaultSolver(self.config)
		replaced_path = model.canonical_iface_uri(os.path.join(mydir, 'Replaced.xml'))
		replaced_conflicts_path = model.canonical_iface_uri(os.path.join(mydir, 'ReplacedConflicts.xml'))
		r = Requirements(replaced_conflicts_path)
		s.solve_for(r)
		assert s.ready, s.get_failure_reason()
		assert s.selections
		self.assertEqual("b", s.selections.selections[replaced_conflicts_path].id)
		self.assertEqual("2", s.selections.selections[replaced_conflicts_path].version)
		self.assertEqual("sha1=3ce644dc725f1d21cfcf02562c76f375944b266a", s.selections.selections["http://localhost:8000/Hello"].id)
		self.assertEqual(2, len(s.selections.selections))

		s.extra_restrictions[self.config.iface_cache.get_interface(r.interface_uri)] = [
				model.VersionRangeRestriction(model.parse_version('2'), None)]

		s.solve_for(r)
		assert s.ready, s.get_failure_reason()
		assert s.selections
		self.assertEqual("1", s.selections.selections[replaced_conflicts_path].version)
		self.assertEqual("0", s.selections.selections[replaced_path].version)
		self.assertEqual(2, len(s.selections.selections))
开发者ID:michel-slm,项目名称:0install,代码行数:23,代码来源:testsolver.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python model.escape函数代码示例发布时间:2022-05-26
下一篇:
Python driver.Driver类代码示例发布时间: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