当前位置: 首页>>代码示例>>Python>>正文


Python arch.get_architecture函数代码示例

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


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

示例1: testLangs

	def testLangs(self):
		iface_cache = self.config.iface_cache
		try:
			locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

			s = solver.DefaultSolver(self.config)
			iface = iface_cache.get_interface('http://foo/Langs.xml')
			self.import_feed(iface.uri, 'Langs.xml')

			# 1 is the oldest, but the only one in our language
			binary_arch = arch.get_architecture(None, 'arch_1')
			s.solve('http://foo/Langs.xml', binary_arch)
			assert s.ready
			self.assertEquals('sha1=1', s.selections[iface].id)

			# 6 is the newest, and close enough, even though not
			# quite the right locale
			binary_arch = arch.get_architecture(None, 'arch_2')
			s.solve('http://foo/Langs.xml', binary_arch)
			assert s.ready
			self.assertEquals('sha1=6', s.selections[iface].id)

			# 9 is the newest, although 7 is a closer match
			binary_arch = arch.get_architecture(None, 'arch_3')
			s.solve('http://foo/Langs.xml', binary_arch)
			assert s.ready
			self.assertEquals('sha1=9', s.selections[iface].id)

			# 11 is the newest we understand
			binary_arch = arch.get_architecture(None, 'arch_4')
			s.solve('http://foo/Langs.xml', binary_arch)
			assert s.ready
			self.assertEquals('sha1=11', s.selections[iface].id)

			# 13 is the newest we understand
			binary_arch = arch.get_architecture(None, 'arch_5')
			s.solve('http://foo/Langs.xml', binary_arch)
			assert s.ready
			self.assertEquals('sha1=13', s.selections[iface].id)

			def check(target_arch, langs, expected):
				s.langs = langs
				binary_arch = arch.get_architecture(None, target_arch)
				s.solve('http://foo/Langs.xml', binary_arch)
				assert s.ready
				self.assertEquals(expected, s.selections[iface].id)

			# We don't understand any, so pick the newest
			check('arch_2', ['es_ES'], 'sha1=6')

			# These two have the same version number. Choose the
			# one most appropriate to our country
			check('arch_6', ['zh_CN'], 'sha1=15')
			check('arch_6', ['zh_TW'], 'sha1=16')

			# Same, but one doesn't have a country code
			check('arch_7', ['bn'], 'sha1=17')
			check('arch_7', ['bn_IN'], 'sha1=18')
		finally:
			locale.setlocale(locale.LC_ALL, '')
开发者ID:pombredanne,项目名称:zero-install,代码行数:60,代码来源:testsolver.py

示例2: testMultiArch

	def testMultiArch(self):
		iface_cache = self.config.iface_cache
		s = solver.DefaultSolver(self.config)

		foo = iface_cache.get_interface('http://foo/MultiArch.xml')
		self.import_feed(foo.uri, 'MultiArch.xml')
		lib = iface_cache.get_interface('http://foo/MultiArchLib.xml')
		self.import_feed(lib.uri, 'MultiArchLib.xml')

		# On an i686 system we can only use the i486 implementation

		binary_arch = arch.get_architecture('Linux', 'i686')
		s.solve('http://foo/MultiArch.xml', binary_arch)
		assert s.ready
		assert s.selections[foo].machine == 'i486'
		assert s.selections[lib].machine == 'i486'

		# On an 64 bit system we could use either, but we prefer the 64
		# bit implementation. The i486 version of the library is newer,
		# but we must pick one that is compatible with the main binary.

		binary_arch = arch.get_architecture('Linux', 'x86_64')
		s.solve('http://foo/MultiArch.xml', binary_arch)
		assert s.ready
		assert s.selections[foo].machine == 'x86_64'
		assert s.selections[lib].machine == 'x86_64'
开发者ID:pombredanne,项目名称:zero-install,代码行数:26,代码来源:testsolver.py

示例3: testArch

	def testArch(self):
		host_arch = arch.get_host_architecture()
		host_arch2 = arch.get_architecture(None, None)
		self.assertEquals(host_arch.os_ranks, host_arch2.os_ranks)
		self.assertEquals(host_arch.machine_ranks, host_arch2.machine_ranks)

		other = arch.get_architecture('FooBar', 'i486')
		self.assertEquals(2, len(other.os_ranks))

		assert 'FooBar' in other.os_ranks
		assert None in other.os_ranks
		assert 'i486' in other.machine_ranks
		assert 'ppc' not in other.machine_ranks
开发者ID:pombredanne,项目名称:zero-install,代码行数:13,代码来源:testsolver.py

示例4: get_arch_for

	def get_arch_for(self, requirements, interface = None):
		"""Return the Architecture we would use when solving for this interface.
		Normally, this architecture is constructed from the OS and CPU type in the requirements,
		using the host platform's settings if these are not given.
		If interface is the root, then we wrap this in a SourceArchitecture if looking
		for source code and (for backwards compatibility) we enable use="testing" dependencies
		if the command is "test".
		@param requirements: the overall requirements for the solve
		@type requirements: L{requirements.Requirements}
		@param interface: the interface of interest
		@type interface: L{model.Interface}
		@return: the architecture that would be used
		@rtype: L{architecture.Architecture}
		@since: 1.9"""
		root_arch = arch.get_architecture(requirements.os, requirements.cpu)
		if interface is None or interface.uri == requirements.interface_uri:
			if requirements.source:
				root_arch = arch.SourceArchitecture(root_arch)
			if requirements.command == 'test':
				# This is for old feeds that have use='testing' instead of the newer
				# 'test' command for giving test-only dependencies.
				root_arch = arch.Architecture(root_arch.os_ranks, root_arch.machine_ranks)
				root_arch.use = frozenset([None, "testing"])
			return root_arch
		# Assume we use the same arch for all descendants
		return root_arch.child_arch
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:26,代码来源:solver.py

示例5: __init__

    def __init__(self, config, requirements):
        """
		@param config: The configuration settings to use
		@type config: L{config.Config}
		@param requirements: Details about the program we want to run
		@type requirements: L{requirements.Requirements}
		@since: 0.53
		"""
        self.watchers = []

        assert config
        self.config = config

        assert requirements
        self.requirements = requirements

        self.target_arch = arch.get_architecture(requirements.os, requirements.cpu)

        from zeroinstall.injector.solver import DefaultSolver

        self.solver = DefaultSolver(self.config)

        logger.debug(_("Supported systems: '%s'"), arch.os_ranks)
        logger.debug(_("Supported processors: '%s'"), arch.machine_ranks)

        if requirements.before or requirements.not_before:
            self.solver.extra_restrictions[config.iface_cache.get_interface(requirements.interface_uri)] = [
                model.VersionRangeRestriction(
                    model.parse_version(requirements.before), model.parse_version(requirements.not_before)
                )
            ]
开发者ID:timdiels,项目名称:0install,代码行数:31,代码来源:driver.py

示例6: testFeedBug

	def testFeedBug(self):
		self.import_feed('http://foo/Build.xml', 'Build.xml')
		self.import_feed('http://foo/Compiler.xml', 'Compiler.xml')
		self.import_feed('http://foo/Compiler-new.xml', 'Compiler-new.xml')
		s = solver.DefaultSolver(self.config)
		s.solve('http://foo/Build.xml', arch.get_architecture(None, None))
		assert s.ready, s.get_failure_reason()
		assert s.selections
开发者ID:michel-slm,项目名称:0install,代码行数:8,代码来源:testsolver.py

示例7: assertSelection

def assertSelection(expected, repo):
	cache = TestCache()

	expected = [tuple(e.strip().split('-')) for e in expected.split(",")]

	for line in repo.split('\n'):
		line = line.strip()
		if not line: continue
		if ':' in line:
			prog, versions = line.split(':')
			prog = prog.strip()
			if ' ' in prog:
				prog, prog_arch = prog.split()
			else:
				prog_arch = None
			for v in versions.split():
				cache.get_prog(prog).get_version(v).arch = prog_arch
		elif '=>' in line:
			prog, requires = line.split('=>')
			prog, version_range = prog.strip().split('[')
			lib, min_v, max_v = requires.split()
			assert version_range.endswith(']')
			version_range = version_range[:-1]
			if ',' in version_range:
				min_p, max_p = map(int, version_range.split(','))
				prog_versions = range(min_p, max_p + 1)
			else:
				prog_versions = [int(version_range)]
			for prog_version in prog_versions:
				cache.get_prog(prog).get_version(str(prog_version)).add_requires(lib, min_v, max_v)

	root = uri_prefix + expected[0][0]

	class TestConfig:
		help_with_testing = False
		network_use = model.network_offline
		stores = stores
		iface_cache = cache

	s = Solver(TestConfig())
	s.solve(root, arch.get_architecture('Linux', 'x86_64'))

	if expected[0][1] == 'FAIL':
		assert not s.ready
	else:
		assert s.ready

		actual = []
		for iface_uri, impl in s.selections.selections.items():
			actual.append(((iface_uri.rsplit('/', 1)[1]), impl.version))

		expected.sort()
		actual.sort()
		if expected != actual:
			raise Exception("Solve failed:\nExpected: %s\n  Actual: %s" % (expected, actual))
	return s
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:56,代码来源:testsat.py

示例8: solve_for

	def solve_for(self, requirements):
		"""Solve for given requirements.
		@param requirements: the interface, architecture and command to solve for
		@type requirements: L{requirements.Requirements}
		@postcondition: self.ready, self.selections and self.feeds_used are updated
		@since: 1.8"""
		root_arch = arch.get_architecture(requirements.os, requirements.cpu)
		if requirements.source:
			root_arch = arch.SourceArchitecture(root_arch)
		return self.solve(requirements.interface_uri, root_arch, requirements.command)
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:10,代码来源:solver.py

示例9: __init__

	def __init__(self, root = None, handler = None, src = None, command = -1, config = None, requirements = None):
		"""
		@param requirements: Details about the program we want to run
		@type requirements: L{requirements.Requirements}
		@param config: The configuration settings to use, or None to load from disk.
		@type config: L{ConfigParser.ConfigParser}
		Note: all other arguments are deprecated (since 0launch 0.52)
		"""
		self.watchers = []
		if requirements is None:
			from zeroinstall.injector.requirements import Requirements
			requirements = Requirements(root)
			requirements.source = bool(src)				# Root impl must be a "src" machine type
			if command == -1:
				if src:
					command = 'compile'
				else:
					command = 'run'
			requirements.command = command
			self.target_arch = arch.get_host_architecture()
		else:
			assert root == src == None
			assert command == -1
			self.target_arch = arch.get_architecture(requirements.os, requirements.cpu)
		self.requirements = requirements

		self.stale_feeds = set()

		if config is None:
			self.config = load_config(handler or Handler())
		else:
			assert handler is None, "can't pass a handler and a config"
			self.config = config

		from zeroinstall.injector.solver import DefaultSolver
		self.solver = DefaultSolver(self.config)

		# If we need to download something but can't because we are offline,
		# warn the user. But only the first time.
		self._warned_offline = False

		debug(_("Supported systems: '%s'"), arch.os_ranks)
		debug(_("Supported processors: '%s'"), arch.machine_ranks)

		if requirements.before or requirements.not_before:
			self.solver.extra_restrictions[config.iface_cache.get_interface(requirements.interface_uri)] = [
					model.VersionRangeRestriction(model.parse_version(requirements.before),
								      model.parse_version(requirements.not_before))]
开发者ID:pombredanne,项目名称:zero-install,代码行数:48,代码来源:policy.py

示例10: testRanking

	def testRanking(self):
		iface_cache = self.config.iface_cache
		s = solver.DefaultSolver(self.config)
		ranking = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'Ranking.xml')

		binary_arch = arch.get_architecture('Linux', 'x86_64')
		selected = []
		while True:
			s.solve(ranking, binary_arch)
			if not s.ready:
				break
			impl = s.selections.selections[ranking]
			selected.append(impl.version + ' ' + impl.attrs['arch'])
			iface_cache.get_feed(ranking).implementations[impl.id].arch = 'Foo-odd'		# prevent reselection
		self.assertEqual([
			'0.2 Linux-i386',	# poor arch, but newest version
			'0.1 Linux-x86_64',	# 64-bit is best match for host arch
			'0.1 Linux-i686', '0.1 Linux-i586', '0.1 Linux-i486'],	# ordering of x86 versions
			selected)
开发者ID:rammstein,项目名称:0install,代码行数:19,代码来源:testsolver.py

示例11: testOs

	def testOs(self):
		arch = get_architecture('MacOSX', 'ppc')
		assert ('Darwin' in arch.os_ranks)
开发者ID:linuxmidhun,项目名称:0install,代码行数:3,代码来源:testarch.py

示例12: justify_decision

	def justify_decision(self, requirements, iface, impl):
		"""Run a solve with impl_id forced to be selected, and explain why it wasn't (or was)
		selected in the normal case.
		@type requirements: L{zeroinstall.injector.requirements.Requirements}
		@type iface: L{zeroinstall.injector.model.Interface}
		@type impl: L{zeroinstall.injector.model.Implementation}
		@rtype: str"""
		assert isinstance(iface, model.Interface), iface

		restrictions = self.extra_restrictions.copy()
		restrictions[iface] = restrictions.get(iface, []) + [_ForceImpl(impl)]
		s = SATSolver(self.config, restrictions)
		s.record_details = True
		s.solve_for(requirements)

		wanted = "{iface} {version}".format(iface = iface.get_name(), version = impl.get_version())

		# Could a selection involving impl even be valid?
		if not s.ready or iface.uri not in s.selections.selections:
			reasons = s.details.get(iface, [])
			for (rid, rstr) in reasons:
				if rid.id == impl.id and rstr is not None:
					return _("{wanted} cannot be used (regardless of other components): {reason}").format(
							wanted = wanted,
							reason = rstr)

			if not s.ready:
				return _("There is no possible selection using {wanted}.\n{reason}").format(
					wanted = wanted,
					reason = s.get_failure_reason())

		actual_selection = self.selections.get(iface, None)
		if actual_selection is not None:
			# Was impl actually selected anyway?
			if actual_selection.id == impl.id:
				return _("{wanted} was selected as the preferred version.").format(wanted = wanted)

			# Was impl ranked below the selected version?
			iface_arch = arch.get_architecture(requirements.os, requirements.cpu)
			if requirements.source and iface.uri == requirements.interface_uri:
				iface_arch = arch.SourceArchitecture(iface_arch)
			wanted_rating = self.get_rating(iface, impl, arch)
			selected_rating = self.get_rating(iface, actual_selection, arch)

			if wanted_rating < selected_rating:
				_ranking_component_reason = [
					_("natural languages we understand are preferred"),
					_("preferred versions come first"),
					_("locally-available versions are preferred when network use is limited"),
					_("packages that don't require admin access to install are preferred"),
					_("more stable versions preferred"),
					_("newer versions are preferred"),
					_("native packages are preferred"),
					_("newer versions are preferred"),
					_("better OS match"),
					_("better CPU match"),
					_("better locale match"),
					_("is locally available"),
					_("better ID (tie-breaker)"),
				]

				actual = actual_selection.get_version()
				if impl.get_version() == actual:
					def detail(i):
						if len(i.id) < 18:
							return " (" + i.id + ")"
						else:
							return " (" + i.id[:16] + "...)"

					wanted += detail(impl)
					actual += detail(actual_selection)

				for i in range(len(wanted_rating)):
					if wanted_rating[i] < selected_rating[i]:
						return _("{wanted} is ranked lower than {actual}: {why}").format(
								wanted = wanted,
								actual = actual,
								why = _ranking_component_reason[i])

		used_impl = iface.uri in s.selections.selections

		# Impl is selectable and ranked higher than the selected version. Selecting it would cause
		# a problem elsewhere.
		changes = []
		for old_iface, old_sel in self.selections.selections.items():
			if old_iface == iface.uri and used_impl: continue
			new_sel = s.selections.selections.get(old_iface, None)
			if new_sel is None:
				changes.append(_("{interface}: no longer used").format(interface = old_iface))
			elif old_sel.version != new_sel.version:
				changes.append(_("{interface}: {old} to {new}").format(interface = old_iface, old = old_sel.version, new = new_sel.version))
			elif old_sel.id != new_sel.id:
				changes.append(_("{interface}: {old} to {new}").format(interface = old_iface, old = old_sel.id, new = new_sel.id))

		if changes:
			changes_text = '\n\n' + _('The changes would be:') + '\n\n' + '\n'.join(changes)
		else:
			changes_text = ''

		if used_impl:
#.........这里部分代码省略.........
开发者ID:AlexanderRyzhko,项目名称:0install-TUF,代码行数:101,代码来源:solver.py

示例13: testMachine

	def testMachine(self):
		arch = get_architecture('Linux', 'i686')
		assert ('i386' in arch.machine_ranks)
开发者ID:linuxmidhun,项目名称:0install,代码行数:3,代码来源:testarch.py

示例14: check

			def check(target_arch, langs, expected):
				s.langs = langs
				binary_arch = arch.get_architecture(None, target_arch)
				s.solve('http://foo/Langs.xml', binary_arch)
				assert s.ready
				self.assertEquals(expected, s.selections[iface].id)
开发者ID:pombredanne,项目名称:zero-install,代码行数:6,代码来源:testsolver.py

示例15: testDefault

	def testDefault(self):
		arch = get_architecture(None, None)
		assert arch
开发者ID:linuxmidhun,项目名称:0install,代码行数:3,代码来源:testarch.py


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